mongodb ?
What I'm trying to do here is check if the userid is within the likes array: if yes, then pull it from the array, else push it into the array
I came up with this snippet but it does not work at all.
I've tested the $pull and $push expressions separately and they work as intended, so I'm pretty sure that I'm doing something wrong with the $cond operator
I think you want the second param to be: [ { $set: { likes: { $cond: { ... } } } } ] Untested
Обсуждают сегодня