Meteor Smart Package providing RethinkDB support for Meteor
- Write wonderful ReQL syntax on both client (Minirethink) and server (RethinkDB) side
- Perform queries faster* by avoiding database polling and the LiveResultsSet
- Don't write Mongo syntax (again, ever.)
Install RethinkDB from Atmosphere
$mrt add rethink-live-data
Install From Git (If you are not using Meteorite)
mkdir -p packages
git submodule add https://github.com/tuhinc/rethink-livedata.git packages/rethink-livedata
Replace Meteor.Collection
with Meteor.Table
.
// old code
Posts = new Meteor.Collection('posts');
// with rethink-live-data
Posts = new Meteor.Table('posts');
On the client side, create an instance of Minirethink to use ReQL syntax instead of Mongo syntax.
// instantiate Minirethink
var r = new Minirethink();
// interact with database using ReQL syntax
r.table('posts').get('username').run(callback);
Continue to use publish and subscribe as you normally would. (rethink-live-data does not currently support autopublish)
// server: publish the posts table.
Meteor.publish('posts', function () {
return r.table('posts').run(callback);
});
// client: subscribe to the posts table
Meteor.subscribe('posts');
// client will queue incoming post records until ...
Posts = new Meteor.Table('posts');
Currently provides support for each
, map
, fetch
, count
, and hasNext
Lazily iterate over the result set one element at a time.
cursor.each(callback[, onFinished])
Transform each element of the sequence by applying the given mapping function.
cursor.map(mappingFunction) → array
Returns an array of all documents in the cursor
cursor.fetch() → array
Transform each element of the sequence by applying the given mapping function.
cursor.count() → integer
Check if there are more elements in the cursor
cursor.hasNext() → bool
- Currently does not support autopublish -- publish and subscribe functions must be used!
Disclaimers:
- This is a work-in-progress. Full functionality has not yet been implemented. There are definitely bugs! :)
-
- this claim has not been tested