Cursor changeCursor = r.table("users").changes().run(conn);
for (Object change : changeCursor) {
System.out.println(change);
}我只需要知道更改一次。我知道"changeCursor.close()“可以停止提要。问题是我怎么知道这次变化的大小!
如果添加了三个用户,"System.out.println(change)“将执行三次。如果只添加了一个用户,"System.out.println(change)“将执行一次。然后,我需要在RethinkDB中unSubscribe Changefeeds。
changeCursor.toList();
changeCursor.iterator();什么也不做!
changeCursor.hasNext();总是正确的!
我不知道更改的次数。我不知道何时执行changeCursor.close()方法。
发布于 2016-05-08 03:22:42
我不太清楚你在问什么。您似乎希望立即获得第一个更改,然后关闭它。
您可以使用javascrip驱动程序执行以下操作:
var r = require('rethinkdb')
r.connect({
host: 'localhost',
port: 28015,
})
.then(function(conn) {
return r.table('users').changes().run(conn)
})
.then(function(cursor) {
cursor.next()
.then(function(doc) {
console.log(doc)
//Ok, now right after we get the first doc, we will close the cursor
cursor.close()
// if we want, we can also close connection
// cursor.close().then(conn.close())
})
})https://stackoverflow.com/questions/37088614
复制相似问题