给出一个类似的例子
r .table('posts')
.get(100)
.merge(function (post) {
return {
comments: r.table('comments').getAll(post('id'),
{index: 'postId'}).coerceTo('array')
}
})
.pluck({"comments": ["id", "created_on"]});
我如何进一步过滤评论,只返回特定用户对给定博客文章的评论。Ie.获取博客文章100并通过user_name=="darth"返回评论
提示非常感谢
最后进行了以下操作:
r
.table('posts')
.get(100)
.merge(function (post) {
return {
comments: r
.table('comments')
.getAll(post('id'), {index: 'postId'})
.coerceTo('array')
.filter(function (row) {
return r.expr(['darth', 'luke', 'chewey']).contains(row('user_name'));
})
}
})
.pluck({"comments": ["id", "user_name", "created_on"]});