rethinkdbrethinkdb-python

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?


Solution

  • 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').