Reputation: 7
my Schema is
var User = new mongoose.Schema({
//general information
name : {type:String},
email : {type : String},
number : {type : String},
password : {type:String},
//featured information
path: { type: String},
dob : {type:String},
gender : {type : String},
blood_group : {type:String},
marital_status : {type : String}
});
module.exports = mongoose.model('user',User);
i want to use update some details by-
app.post('/contactinfo',function (req,res) {
var name = req.body.name;
var number = req.body.number;
var email = req.body.email;
User.update({_id : userID},{
$push : {
name : name,
number : number,
email : email
}
},{new : true },function (err,result) {
if(err){
console.log(err);
}
else{
console.log(result);
res.send({status : "success" , message : "Details updates"});
}
});
});
I don't define array anywhere
but the problem is that is show error on updating
{ MongoError: The field 'name' must be an array but is of type string in document {_id: ObjectId('5a0880e2d767e8131807e7f4')}
I am stuck here
please someone help me in solving this error
Upvotes: 0
Views: 1724