问问题
216 次
1 回答
2
你实际上做得对,几乎就在那里。您只是碰巧使用filter
了错误的键。
r.db('myDb').table('myTable').getNearest(r.point(-20, 39), {index: 'location'})
.filter(function(user) {
return user('doc')('id').ne('2ff8902e-97f0-431a-a51c-900a57532967')
})
关键是:
getNearest
返回一个文档数组。每个文档都有两个字段:dist
和doc
(它是表本身的文档)。因此,我们在这里使用user('doc')('id')
来获取密钥。 https://rethinkdb.com/api/javascript/get_nearest/- 在
filter
函数内部,我们必须使用 ReQL 命令,在这种情况下,ne
均值,不等于。https://www.rethinkdb.com/api/javascript/ne/
这很快,因为我们在位置上有索引。并且filter
函数在 RethinkDB 服务器上执行。
于 2015-10-21T19:16:47.043 回答