1

Using the example here, I've only added one more level to notes, it's mapped to an object whose elements themselves hold arrays

{
    id: 10001,
    name: "Bob Smith",
    notes: {
        alpha:['note1','note2','note3'],
        beta:['note1','note2','note3']
    }
}

Cannot for the life of me figure out how to append elements to alpha and beta however. I've tried variations of this:

update({ 
    notes:{  
        alpha: r.row("alpha").append('note4')  
    } 
})

but am not really getting anywhere.
Any help would be much appreciated~

Oh and the error message was No attribute 'alpha' in object:

House3272
  • 1,007
  • 5
  • 14
  • 29

1 Answers1

1

You could do something like the following:

r.db('test')
 .table('user')
 .get('10001')
 .update({
   notes: {
     alpha: r.row('notes')('alpha').append('note4'),
     beta: r.row('notes')('beta').append('note4')
   }
 }).run();
Tholle
  • 108,070
  • 19
  • 198
  • 189
  • @House3272 Yeah :) It's easy to forget that you have to include the entire path (`('notes')('alpha')`) and not just the field you want to update (`('alpha')`). No problem! – Tholle Feb 29 '16 at 05:09