Lors de la mise à jour des documents du film, on obtient une valeur de la collection User et on la sauvegarde avec les documents mis à jour dans le film.
Movie.pre('update', function (next) {
var id = this._update.$set.userid;
var some = this;
User.findOne({userid: id}, function(err, post) {
// how should we add the firstname to current movie document and
let update query update it all. Something like this...
some.firstname = post.firstname;
next();
});
});
// update query
Movie.statics.saveMovieDetails = function(requestData, callback) {
this.update({userid:requestData.userid},
{ $set:{
userid : requestData.userid,
name : requestData.name,
location : requestData.location,
language : requestData.language,
date : requestData.date
}
},{upsert:true}, callback);
};