RethinkDB listen for changes on filter query? -
i'm not sure if understand changefeeds correct... need filter data based on current date this:
r.table("messages") .filter( r.row("start").lt(r.now().toiso8601()) .and(r.row("end").gt(r.now().toiso8601())) ) .changes() .run(conn, (err, cursor) => { if (err) { throw err; } cursor.each(function (err, row) { if (err) { throw err; } // stuff here }); });
});
is possible this? or .changes() work if field of row updated?
it's possible , syntax right.
however, note in case miss it. r.now()
evaluated first time ever run query, not current time when changes happens. r.now() calculated 1 time in same query , return value re-use on sub sequent calls: https://www.rethinkdb.com/api/javascript/now/
changefeeds works both of insert , updating. if insert/updated document match condition of filter
, return in cursor. if it's insert, old_val
null
, if it's update, old_val old value.
Comments
Post a Comment