With Mongoid, I'm trying to do :
models.update_all({
'$pullAll' => { category_ids: removed_category_ids },
'$addToSet' => { category_ids: { '$each' => added_category_ids } }
})
I have this error message :
Mongo::Error::OperationFailure:
Cannot update 'category_ids' and 'category_ids' at the same time (16837)
I understand the error but is there a way to do those two requests in only one query. I know I can do something like :
models.update_all({ '$pullAll' => { category_ids: removed_category_ids } })
models.update_all({ '$addToSet' => { category_ids: { '$each' => added_category_ids } } })
but it do two calls and models
can have changed. I can do something to keep the first value to do the second query but I would prefer to do it in the same if it's possible.
Is it possible?