How to get real time updates from database

25 views
Skip to first unread message

Dhananjay Mangela

unread,
Sep 24, 2020, 8:00:03 AM9/24/20
to RethinkDB
I m using node.js with rethink db.
how can i achieved real time updates from database

Johannes Hillert

unread,
Sep 24, 2020, 1:08:27 PM9/24/20
to RethinkDB
You can use the 'changes' command to get notifications when something changes on the DB side.. https://rethinkdb.com/api/javascript/changes/

Dhananjay Mangela

unread,
Sep 25, 2020, 2:14:18 AM9/25/20
to reth...@googlegroups.com
how can i also update front end with changes in database ?


--
You received this message because you are subscribed to the Google Groups "RethinkDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rethinkdb+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rethinkdb/2370adec-f22a-4b4e-9b79-0b6cb6d7c481n%40googlegroups.com.

Johannes Hillert

unread,
Sep 25, 2020, 4:05:02 AM9/25/20
to RethinkDB
Yes, you can update your frontend when 'changes' emits a new value.

I never used the JavaScript API of RethinkDB, but it looks like an observable. Judging from the examples on the page, I'd say it runs like this:

r.table('games').get(1).filter(r.row('score').gt(10)).changes().run(conn, (err, cursor) => {
// A change in the DB was made -> update frontend
cursor.each(console.log);
});

With the callback method to your update method as 2nd parameter of 'run'.

Kind regards,
Johannes
Reply all
Reply to author
Forward
0 new messages