I'm learning RethinkDB and of course I'm interesting in using changes()
method to get changefeed.
I know how to start them but the docs are not clear about how to stop a changefeed? Should I just call close()
on the cursor
passed into run()
method or there is another way?
Here is the doc you're looking for:
https://rethinkdb.com/api/javascript/close-cursor/
And a quick example:
let c;
r.connect({host: "localhost", post: 28015}, (err, conn) => {
c = conn;
});
r.db("test").table("test").changes().run(c, (err, cursor) => {
let cursor = cursor;
cursor.each((item) => {
console.log(item);
});
});
setTimeout(() => { cursor.close() }, 5000);