A database API for Meteor
Clone or download
Latest commit 0bd838d Oct 25, 2016
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github unmaintained Oct 25, 2016
.gitignore first Jun 22, 2015
README.md unmaintained Oct 25, 2016
globals.js new anydb Sep 28, 2015
package.js idk Oct 7, 2015
pub.coffee new anydb Sep 28, 2015
sub.coffee renamed callback to onReady Sep 29, 2015


Meteor Icon


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


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)

# publications must be manually refreshed if you want reactive data
  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)