中止 rethinkdb 更改提要
Abort rethinkdb changefeed
我正在学习 RethinkDB,当然我对使用 changes()
方法获取 changefeed 很感兴趣。
我知道如何启动它们,但文档不清楚如何停止更改源?我应该只在传递给 run()
方法的 cursor
上调用 close()
还是有其他方法?
这是您要查找的文档:
https://rethinkdb.com/api/javascript/close-cursor/
还有一个简单的例子:
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);
我正在学习 RethinkDB,当然我对使用 changes()
方法获取 changefeed 很感兴趣。
我知道如何启动它们,但文档不清楚如何停止更改源?我应该只在传递给 run()
方法的 cursor
上调用 close()
还是有其他方法?
这是您要查找的文档:
https://rethinkdb.com/api/javascript/close-cursor/
还有一个简单的例子:
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);