I need to update a specific document (by _id) and lower in DB a specific field by 1.
The query looks like this :
mycollection.update_one({"_id": {"$eq": the_id}}, {"$inc": {"fieldToLower": -1}})
However i need the fieldToLower to never be negative, that mins equals to 0 in case it's already 0, and not equal to -1.
I would like to know how can i do that in this query ?