Reputation: 10413
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});
Upvotes: 0
Views: 1135
Reputation: 4962
You can't use dot-notation as a JSON key unless you quote the key, like this:
SeriesModel.update({"features.tvdb_id" : serieData.id}, instance, {upsert: true});
Upvotes: 5