gpt4 book ai didi

javascript - RethinkDB - 将 getNearest() 与 eqJoin() 结合使用

转载 作者:行者123 更新时间:2023-11-28 15:30:45 24 4
gpt4 key购买 nike

这按预期工作,在某个位置获取所有“签到”

r.table('places').eqJoin('checkinId', r.table('checkins'))

这按预期工作,获取某个点附近的所有位置。

r.table('places').getNearest(r.point(-122.1634581999,47.7542651), { index : 'places.location' })

但这会返回一个空数组,获取某个点附近的所有位置,然后加入 checkin 。

r.table('places').getNearest(r.point(-122.1634581999,47.7542651), { index : 'places.location' }).eqJoin('checkinId', r.table('checkins'))

我应该以不同的方式加入第二个表吗?

最佳答案

我认为getNearest返回格式为 {distance: <number>, doc: <doc>} 的流,所以你可能必须替换 checkinIdeqJoinr.row("doc")("checkinId")

所以类似

r.table("places").getNearest(...).eqJoin(r.row("doc")("checkinId"), r.table("checkins"))

之所以没有返回任何内容是因为eqJoin行为类似于 SQL 内连接,这意味着如果未找到匹配项,则不会返回左侧文档。

关于javascript - RethinkDB - 将 getNearest() 与 eqJoin() 结合使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27464880/

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