I have a document that looks similar to the following
{
...
reactions: [
{
user: 'user_id',
reaction: 'reaction_name'
}, {
user: 'user_id',
reaction: 'reaction_name'
}
]
...
}
I'm trying to remove an item in the array reactions based on a combination of 'user' and 'reaction' which will be unique. How would I go about filtering the reactions array to remove that specific item in rethinkdb using the js driver?
I've tried this
r.db('db_name').table('messages').getAll(
get_single_message
).update({
reactions: r.row('reactions').filter( (item) => {
return item('reaction').ne(body.reaction).and(item('user').ne(body.user))
})
}).run(this._rdbConn)
I understand why it doesn't work (returns all reactions that don't have given reaction, then returns subset of that array that doesn't have certain user). What I want is for those not equals to be performed in sync so it returns an array that doesn't include items that have the provided reaction AND user. Right now it functions more like reaction OR user.