简单的Schema min规则不会给出错误

时间:2016-09-12 08:50:53

标签: meteor simple-schema

我试图用$ push和$ inc同时更新,每件事情都运行良好但问题是当我的字段中包含负值时,其最小值不应该小于0我已在模式中设置了规则min,但它没有给出错误,将字段值设置为负数。

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. 
                }
        }

0 个答案:

没有答案