使用示例 here ,我只在 notes
中添加了一层,它被映射到一个其元素本身保存数组的对象
{
id: 10001,
name: "Bob Smith",
notes: {
alpha:['note1','note2','note3'],
beta:['note1','note2','note3']
}
}
但是我一生都无法弄清楚如何将元素附加到 alpha
和 beta
中。我尝试过以下变体:
update({
notes:{
alpha: r.row("alpha").append('note4')
}
})
但我并没有真正取得任何进展。
任何帮助将不胜感激〜
哦,错误消息是对象中没有属性“alpha”:
最佳答案
您可以执行以下操作:
r.db('test')
.table('user')
.get('10001')
.update({
notes: {
alpha: r.row('notes')('alpha').append('note4'),
beta: r.row('notes')('beta').append('note4')
}
}).run();
关于javascript - RethinkDB,将元素添加到嵌套的数组中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35692170/