Mongoose $ inc什么都不做

时间:2018-06-08 10:31:45

标签: node.js mongodb mongoose increment mongoose-schema

这是我的Mongoose架构:

var mongoose = require('mongoose');

// define the schema for our campaign model
var campaignSchema = mongoose.Schema({
    name:String,
    priority: Number,
    start: String,
    end: String,
    platforms:[String],
    contents:[
        {
            id:Number,
            img:String,
            link:String,
            height:Number,
            width:Number,
            views:Number,
            clicks:Number
        }
    ]  
});

// create the model for campaigns and expose it to our app
module.exports = mongoose.model('Campaign', campaignSchema);

当我尝试增加任何Number字段时,无论是contents数组还是priority,它都不会执行任何操作,没有错误,值只保持不变...

这就是我尝试这样做的方法:

Campaign.update({"_id": req.query.campaignID}, {$inc : {priority : 1} });

但它的价值保持0

为了防止您提出问题,我尝试将campaign_id == req.query.campaignID联系起来并存在

0 个答案:

没有答案