I do this after a mongoose .find
query:
data2[0].videos[temp].markModified('fakeName');
data2[0].save(function(err,product,numberAffected){
if(err){
console.log("error saving manifest")
console.log(err);
var back={success:false, reason:err};
callback(back);
return;
}
if(numberAffected>=1){
console.log("manifest saved",product.videos[temp]);
var back={success:true};
callback(back);
return;
}else{
console.log("nothing saved");
callback({success:false});
return;
}
});
Which prints this:
manifest saved { fakeName: 'devrenameTest',
name: 'bkdyZVb--',
version: 1,
dateCreated: 1406846165732,
dateUpdated: 1406846165732,
vidLoc: '[url removed]',
thumbLoc: '[url removed]',
author: '53a47a469c52c9d83a2d71d9',
_id: 53dac4d533c061dd0b000007,
sharedWithGroups: [],
sharedWith: [],
tags: [] }
So it appears to have worked right?
But then if I look on my database, I see a subdoc inside of videos
made up only of one fakeName
field, and the object that I was modifying is without a fakeName
field.
What's going on?
I changed the first line up there to
data2[0].markModified('videos');
And that seemed to fix it.
I'd still accept answers based on an explanation of what is happening.