0

How to insert blow document

  {
      "author": "Vic Zhao",
      "text":  "hell..............."
  }

into blow document as first element of embedded array comments

{
   name: 'Me',
   comments: [{
      "author": "Joe S.",
      "text": "I'm Thirsty"
   },
  {
      "author": "Adder K.",
      "text":  "old content"
  }]
}
jeb
  • 78,592
  • 17
  • 171
  • 225
Alex Luya
  • 9,412
  • 15
  • 59
  • 91

1 Answers1

2

you can use the prepend operation http://www.rethinkdb.com/api/#js:document_manipulation-prepend

r.table(...).get(...).update({
    comments: r.row('comments').prepend(newEntry)
  }).run(conn, callback)

Where newEntry must be replaced by the data you want to insert.

Daniel Mewes
  • 1,876
  • 14
  • 16