gpt4 book ai didi

javascript - 中止 rethinkdb 更改提要

转载 作者:搜寻专家 更新时间:2023-11-01 00:40:34 24 4
gpt4 key购买 nike

我正在学习 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);

关于javascript - 中止 rethinkdb 更改提要,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35963349/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com