rethinkdbreqldatabasenosql

ReQL Updating object inside an embedded array emits "create" and "delete" events when listening to changes


I am hitting the following problem: Suppose that I have the following structure:

{
    "id": 1,
    "data": {
       "arr": [{"text":"item1"}]
    }
}

And the following query:

r.db('test').table('test').get(1).update(function (item) {
    return {
        data: {
          arr: item('data')('arr').map(function (row) {
             return r.branch(
                  row('text').eq('item1'),
                  row.merge({updated:true}),
                  row
             )
          })
        }
    }
})

I am listening for changes in this specific array only, and when the item is updated both create and delete events are emitted. I really need to receive an update event, e.g. old_val is not null and new_val is not null.

Thanks in advance guys


Solution

  • After all, I decided to drop the embedded array and use table joins, this avoids all possible hacks.