Answer the question
In order to leave comments, you need to log in
How to organize storage and correctly update ObjectId in an array?
Scheme
var schema = new Schema({
mail:{
type: String,
unique: true,
required: true
},
hashedPassword: {
type: String,
required: true
},
salt:{
type: String,
required: true
},
name:{
type: String,
required: true
},
surname:{
type: String,
required: true
},
avatar:{
type: String
},
date:{
type: Date,
default: Date.now
},
friends: [
Schema.Types.ObjectId
]
});
[
{id}
{id}
]
var addingId = new ObjectID(req.params.id1);
var added = new ObjectID(req.params.id2);
User.insert({_id:addingId},{friends: [added]},function(){
console.log('НАКОНЕЦ ТО ЗАРАБОТАЛО');
})
TypeError: Object function model(doc, fields, skipId) {
if (!(this instanceof model))
return new model(doc, fields, skipId);
Model.call(this, doc, fields, skipId);
} has no method 'insert'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question