Ido Ran
Ido Ran

Reputation: 11384

Abort rethinkdb changefeed

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?

Upvotes: 2

Views: 163

Answers (1)

dalanmiller
dalanmiller

Reputation: 3672

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); 

Upvotes: 4

Related Questions