如何指定我订购的字段?

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)

buildsusers 都有一个 createdDate 字段。我希望结果按 builds table 的 createdDate 排序,但我实际上是按 users table 的顺序获取它们.

如何指定我想使用 builds table 的 createdDate

加入 后,您应该有一个 'right' 对象,其中包含您可以操作的用户。类似于:

r.table('builds')
 .eqJoin('userId', r.table('users'))
 .orderBy(r.desc('right.createdDate'))
 .limit(100)
 .run(connection)

我的问题解释得比较清楚in the 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)

虽然这行得通,但我并不完全理解。完全欢迎任何额外的解释或答案。