0
我有这个JSON文件:RethinkDB:检查是否在数组对象存在并更换
{
userId: xx,
followedAuthors: [
{ authorId: abc, timestamp: 123 },
{ authorId: xyz, timestamp: 456 },
]
}
当用户要遵循一个作家,我想写出检查,如果该作者已经跟随查询,检查id,以及它是否将新的后续作者追加到数组中。
现在我每次创建一个新条目。 这是我的查询:
r.table('users')
.get(userId)
.replace(user => {
return user.merge({
followedTopics: user('followedTopics')
.default([])
.setInsert({ topic: topic, timestamp: now }),
})
})
'Branch'是这个问题的关键,谢谢! – Tres