// Add custom "profilePict()" method on the User Schema
userSchema.methods.profilePicture = function profilePicture() {
// Any type of query can be done here
return this.model('Image').get(this.imageIdx);
const User = require('../models/user.model');
const user = new User({ name: 'John', imageIdx: 1234 });
user.profilePicture = imageEntity.url;
userSchema.methods.profilePict = function(cb) {
return this.model('Image').get(this.imageIdx, cb);
const user = new User({ name:'John', imageIdx:1234 });
// Call custom Method 'getImage'
user.profilePict(function onProfilePict(err, imageEntity) {
user.profilePict = imageEntity.url;
user.save().then(() { ... });