Decrement value MongoDB, prevent negative number
I’m using MongoDB and I have a document where I want to increment a count field. However, I need to ensure that this count does not go below zero. For example, if inc is -2 and the current count is 1, applying $inc will result in -1, which I want to avoid.