I am trying to update with $push and $inc at the same time , every thing is working fine but the problem is when I $inc my field with negative values its minimum value shouldn't be less that 0 as I have set the rule min in my schema but it does not give an error set the field value in negative.
schema.js
mySchema=new SimpleSchema({
"totalImages":{
type:Number,
min:0,
optional:true,
},
})
server.js
jobOrders.update(
{
orderNo:jobNo
},
{
$push:{
//pushing an object in an array this is working as expected
},
$inc:{
totalImages:-2 //lets say the value of totalImages is 0 before, this should give an error since it will set negative value. But doesnot give any error.
}
}