0
votes

this is my schema

name : String, phone : String, address : String

mongoose.model("user",userSchema);

var user = mongoose.model("user");

var newUser = new user({name : "d",phone : "p",address : "q"}); newUser.save();

newUser.findOne({_id : "dsklfj98908"},function(err,result){

 result.set('unlockGames',"puzzle",[String],{strict : false});
 result.save();

});

working wonderful,until i want to change one more time:

//NOT WORKING 1 newUser.findOne({_id : "dsklfj98908"},function(err,result){

 result.get("unlockGames").push("Gag jan stees");
 result.save();

});

//NOT WORKING 2 newUser.findOne({_id : "dsklfj98908"},function(err,result){

 var unlockGames = result.get("unlockGames").push("Gag jan stees");
 result.set('unlockGames',unlockGames,[String],{strict : false});
 result.save();

});

Help please!)

1

1 Answers

0
votes

now it's working

var game = "es chlnei duq inch eiq anelu";

var unlockGames = result.get("unlockGames");

result.unlockGames = unlockGames.push(game);

result.markModified('unlockGames');

that's it);