I am getting an issue while updating a nested object.sample data like this
{
"status":{
"draft":{
"status":"draft",
"rating":4
},
"review":{
"status":"review",
"rating":4
},
"publish":{
"status":"publish",
"rating":4
}
}
}
In the above object some times the draft/ review/ publish are empty objects and need to check the condition and update the rating in the object.I have tried like this but getting error.
query:
r.db('sample_db').table('table').filter({id:'xxxxxxx'})
.update({"draft": r.row('status').map(function(data){
return r.branch(
data('draft').hasFields({'status':true}),
data.merge({ "rating": 100 }),
data
)})
})
Error:
{
"deleted": 0 ,
"errors": 1 ,
"first_error": "Cannot convert OBJECT to SEQUENCE" ,
"inserted": 0 ,
"replaced": 0 ,
"skipped": 0 ,
"unchanged": 0
}
can any one help me to solve this query. Thanks in advance.