Question

I have a josn named "update",and it has an embedded list "comments" like this:

{
   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[...]
                  }
                 ]

   }]
 }

Questions are:

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

Solution

You can use union -- http://www.rethinkdb.com/api/javascript/union/

r.table("update").get("update/0").update({
    comments: r.row("comments").union([comment1, comment2])
})
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top