All Projects → ccorcos → Meteor Any Db

ccorcos / Meteor Any Db

A database API for Meteor

Programming Languages

coffeescript
4710 projects

Meteor Icon

Meteor Any-Db [MAINTAINER WANTED]

This package allows you to use Meteor with any database or data source.

Check out this article.

Getting Started

Simply add this package to your project:

meteor add ccorcos:any-db

API

This works with any arbitrary collection. Every document needs a unique _id field. We'll demonstrate this with Mongo, but you could easily use ccorcos:neo4j or ccorcos:rethink as well.

Subscriptions are limited to only one argument!

Messages = new Mongo.Collection('messages')

# publish an ordered collection
AnyDb.publish 'messages', (roomId) ->
  # make sure any async methods are wrapped in a fiber.
  # every document needs a unique _id field.
  Messages.find({roomId}, {sort: {time: -1}}).fetch()

# subscriptions are limited to only one argument
sub = AnyDb.subscribe 'messages', roomId, (sub) ->
  console.log("sub ready", sub.data)
  sub.onChange (data) ->
    console.log("new sub data", sub.data)
sub.stop()

# publications must be manually refreshed if you want reactive data
Meteor.methods
  newMsg: (roomId, text) ->
    Messages.insert({roomId, text, time: Date.now()})
    # Ramda.js makes these refresh calls really clean
    AnyDb.refresh 'messages', R.propEq('roomId', roomId)
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].