这是我的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
联系起来并存在