How to update nested array using rethinkdb javascript driver -


i've checked other related questions, in particular this one. since answered seems rethink's handling of nested fields has changed.

i'm trying modify nested arrays 'amy' , 'joe':

{     "id":  "blah" ,     "schedules": {         "amy": ['some', 'stuff', 'here'],         "joe": ['more', 'stuff', 'here']     } } 

i've tried kinds of different approaches, can't work in single call database. instead, i'm having grab existing array using 1 call:

r.table('whatevs').get('blah').pluck({schedules: {amy: true}}) 

this gives me looks like:

"schedules": {     "amy": ['some', 'stuff', 'here'] } 

so pull out schedules.amy , modify array then...

r.table('whatevs').get('blah').update({schedules: {amy: [modified_array]}})... 

what i'd modify arrays in place single query using .difference() , .append(). seems possible, no matter syntax try gets rejected.

if want update single key that's array, can this:

r.table('whateves').get('blah').update(function(row) {   return {schedules: {amy: row('schedules')('amy').append('new_value')}}; }); 

Comments