I have the following Schema:
var userSchema = mongoose.Schema({
local : {
email : String,
password : String,
movies : [{
moviename : String,
rating : Number
}],
}
});
And I use the following way to add entries to the array:
user.local.movies.push({ moviename : "Top Gun", rating : 80});
user.save(function (err) {
if (err)
console.log("Error in saving");
res.end(0);
});
But I need to remove entries too. I need to be able to remove entries by the "moviename" name. I tried using pull:
user.local.movies.pull({ moviename : "Top Gun"});
but it did not work.
Could someone please let me know how I can remove entries from the array?
Thank you.
save()afterpull()?