Snippets Collections
var autoPopulate = function(next) {
  this.populate('updated_by','name').populate('created_by','name');
  next();
};

ProjectSchema.pre('findOne', autoPopulate);
ProjectSchema.pre('find', autoPopulate);
star

Thu Feb 16 2023 15:05:38 GMT+0000 (Coordinated Universal Time) https://stackoverflow.com/questions/21592351/mongoose-js-force-always-populate

#javascript #autopopulate

Save snippets that work with our extensions

Available in the Chrome Web Store Get Firefox Add-on Get VS Code extension