Mongoose 更新插入,语法错误
我在使用 Mongoose 进行更新时遇到了问题。它说语法无效,最后一行显示意外的标记“.”
。但我不明白到底出了什么问题。我已经研究了一个多小时了,我是否遗漏了一个简单的概念?
var seriesSchema = new Schema({
type : {type: Number, default: 1},
features: {
tvdb_id: {type: Number, unique: true},
....
},
created : {type: Date}
});
var SeriesModel = mongoose.model('Series', seriesSchema);
var instance = new SeriesModel();
// Setting instance properties to some values
SeriesModel.update({features.tvdb_id : serieData.id}, instance, {upsert: true});
I have experiencing a problem upserting with Mongoose. It says Syntax is invalid, says unexpected token "."
at last line. But I cannot understand what is really wrong. I have been looking into it for more than one hour, am I missing a simple concept?
var seriesSchema = new Schema({
type : {type: Number, default: 1},
features: {
tvdb_id: {type: Number, unique: true},
....
},
created : {type: Date}
});
var SeriesModel = mongoose.model('Series', seriesSchema);
var instance = new SeriesModel();
// Setting instance properties to some values
SeriesModel.update({features.tvdb_id : serieData.id}, instance, {upsert: true});
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
除非您引用该键,否则不能使用点符号作为 JSON 键,如下所示:
You can't use dot-notation as a JSON key unless you quote the key, like this: