Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to append an element to an array in rethinkdb

I have this object:

{
    "id": "eb533cd0-fef1-48bf-9fb8-b66261c9171b" ,
    "errors": [
        "error1" ,
        "error2"
    ]
}

I simply want to append a new error to errors array. I tried:

r.db('test').table('taskQueue').get("eb533cd0-fef1-48bf-9fb8-b66261c9171b").update({'errors': r.row['errors'].append('appended error')})

but this did not work. It gives this error: "TypeError: r.row.errors is undefined"

My question is how to append an array?

like image 348
Sincere Avatar asked Apr 03 '14 19:04

Sincere


1 Answers

r.db('test').table('taskQueue').get("eb533cd0-fef1-48bf-9fb8-b66261c9171b").update({
    errors: r.row('errors').append('appended error')
})

So not r.row['errors'], but r.row('errors').

like image 188
user3778037 Avatar answered Oct 18 '22 20:10

user3778037