So I'm currently trying to perform this operation
return this.model.findByIdAndUpdate(id, { $push: { certifiedBy: certifier } }, { $inc: {score: 1}}, { new: true })
The issue here is that score
will grow without limit, I would like to prevent this and make it so when this is happening it cannot increment if score <= 5
but still add certifier
into my certifiedBy
array.
Can it be done with mongoose directly or do I have to get the object first check if it over 5 and call a different query in that case ?
Thanks