[英]How do I specify which field I am ordering by?
我有一個RQL查詢,如下所示:
r.table('builds')
.orderBy(r.desc('createdDate'))
.limit(100)
.eqJoin('userId', r.table('users'))
.run(connection)
builds
和users
都有一個createdDate
字段。 我期望結果按builds
表的createdDate
排序,但實際上是按照users
表的順序獲取它們。
如何指定要使用builds
表的createdDate
用戶?
在加入后 ,你應該有一個包含用戶一個“正確”的對象,就可以進行操作。 就像是:
r.table('builds')
.eqJoin('userId', r.table('users'))
.orderBy(r.desc('right.createdDate'))
.limit(100)
.run(connection)
我的問題在RethinkDb docs中得到了明確解釋。 尋找without()
的例子
我的查詢最終看起來像這樣:
r.table('builds')
.eqJoin('userId', r.table('users'))
.without({right: 'createdDate'})
.zip()
.orderBy(r.desc('createdDate'))
.limit(100)
.run(connection)
以下似乎也可行,但不建議使用ordered
。
r.table('builds')
.orderBy(r.desc('createdDate'))
.eqJoin('userId', r.table('users'), {ordered: true})
.limit(100)
.run(connection)
雖然這樣做有效,但我還不完全了解。 完全歡迎任何其他解釋或答案。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.