Transform rethinkdb change feeds into node streams
MIT License
npm install rethinkdb-change-stream --save
query
argument is a rethinkdb query object
type
is either insert, update, or deletedata
is an object with two possible fields:
prev
exists if the type is update or delete
next
exists if the type is update or insert
prev
and next
will be instances of their Model classimport changeStream from 'rethinkdb-change-stream'
import User from 'models/User'
// tail all 18 year olds named "Eric"
var query = User.filter({
first_name: 'Eric',
age: 18
}).changes()
var stream = changeStream(query)
stream.on('data', () => {
// obj.type === insert, update, or delete
// obj.data === object with prev and next objects
})
var changeStream = require('rethinkdb-change-stream');
var User = require('models/User');
// tail all 18 year olds named "Eric"
var query = User.filter({
first_name: 'Eric',
age: 18
}).changes();
var stream = changeStream(query);
stream.on('data', function(obj){
// obj.type === insert, update, or delete
// obj.data === object with prev and next objects
});