如何在一次操作中将多个元素附加到嵌入列表?

时间:2014-03-21 05:59:28

标签: rethinkdb

我有一个名为“update”的json,它有一个嵌入式列表“comments”,如下所示:

{
   id: "update/0",
    //comments contains elements with type:comment
    comments: [{
       id:"comment/0"
       content:"old first level comment content..."
       children:[{
                      id:"comment/00",
                      content:""old second level comment content...",
                      children[...]
                  }
                 ]

   }]
 }

问题是:

1, How to append multiple comments to the embed list "comments" in one time operation? 

1 个答案:

答案 0 :(得分:1)

您可以使用union - http://www.rethinkdb.com/api/javascript/union/

r.table("update").get("update/0").update({
    comments: r.row("comments").union([comment1, comment2])
})