我有两个表, users
和 authors
. 用户可以是作者,如果是,则在作者文档中有用户的 id
.
我想要查询的是非作者的所有用户 . 等效的mySQL查询就像是
select * from users left join authors on users.id=authors.userId
where authors.userId is null
我试过的是
r.db('journa').table('authors').outerJoin(
r.db('journa').table('users'),
(author, user) => {
return author.hasFields({'left': 'claimedByUserId'}).not()
}
)
但它不起作用 . 有关如何实现它的任何想法?
1 回答
你几乎是正确的方式 . 您不应该在连接表达式中反转,因为它将返回一组所有不匹配的排列,并且您将无法检测到所需的匹配 . 以下查询似乎可以满足您的需求: