如何在RethinkDB中删除数组中的特定对象

薄荷

我只是想学习RethinkDB。我有点困惑如何删除数组中的单个对象,如果我必须删除此对象,我必须使用的确切查询是什么

 {
        "name":  "Ram" ,
        "username":  "B97bf210-c4d2d-11e6-b783-07b5fev048705"
        }

来自whoLikedIt Array我的数据

        {
        "comments": [ ],
        "id":  "c242c74d-03d9-4963-9a22-4779facb8192" ,
       .....
        "views": 0 ,
        "whoLikedIt": [
        {
        "name":  "Vignesh Warar" ,
        "username":  "d97bf210-c42d-11e6-b783-07b5fe048705"
        },
{
        "name":  "Ram" ,
        "username":  "B97bf210-c4d2d-11e6-b783-07b5fev048705"
        },


        ]
    .....
        }

我的尝试

r.db('image').table('posts').get('c242c74d-03d9-4963-9a22-4779facb8192').update(
  {whoLikedIt:r.row('whoLikedIt').filter({username:"B97bf210-c4d2d-11e6-b783-07b5fev048705"}).delete()}
)

向我抛出错误

e: Cannot nest writes or meta ops in stream operations.  Use FOR_EACH instead in:
露西

你要:

r.db('image').table('posts').get('c242c74d-03d9-4963-9a22-4779facb8192').update(function(row) {
  return {whoLikedIt: row('whoLikedIt').filter(function(obj) {
    return obj('username').ne("B97bf210-c4d2d-11e6-b783-07b5fev048705");
  })};
})

本文收集自互联网,转载请注明来源。

如有侵权,请联系 [email protected] 删除。

编辑于
0

我来说两句

0 条评论
登录 后参与评论

相关文章