mediaSchema.virtual('src').get(function () { return '/media/' + moment(this.date).format('YYYYMM') + '/' + this._id + '/' + this.fileName; });
schoolSchema .virtual('city') .get(function() { return this.cityNameStored || this.LCITY }) .set(function(value) { this.cityNameStored = value })
UserSchema.virtual('password') .set(function (password) { this.salt = crypto.randomBytes(32).toString('base64'); this.hashedPassword = this.encryptPassword(password, this.salt); }) .get(function () { return this.hashedPassword; });
SpotSchema .virtual('thumbnail_url') .get(function() { return `http://${process.env.internalIP}:${process.env.PORT}/files/${this.thumbnail}` })
// bookSchema.virtual("coverImagePath").get(function() { // if (this.coverImageName != null) { // return path.join("/", coverImageBasePath, this.coverImageName); // } // }); bookSchema.virtual("coverImagePath").get(function() { if ((this.coverImage != null) && (this.coverImageType != null)) { return `data:${this.coverImageType};charset=utf-8;base64, ${this.coverImage.toString('base64')}` } });
// virtual field userSchema .virtual("password") .set(function (password) { this._password = password; this.salt = Math.round(new Date().valueOf() * Math.random() + ""); this.hashed_password = this.encryptPassword(password); }) .get(function () { return this._password; });
schema.virtual('isDonation').get(function() { if (this.price == 0||this.price=='0'||this.Product_Group=='DONATION'||this.price=='0.00'||this.price==0.00) { return true; } return false; })
PostSchema.virtual('categoryName').get(() => { const tab = this.category const pair = _.find(config.tabs, _pair => { return _pair[0] === tab }) if (pair) { return pair[1] } else { return '' } })
/** * Virtuals */ UserSchema.virtual('password').set(function(password) { this._password = password; this.salt = this.makeSalt(); this.hashed_password = this.hashPassword(password); }).get(function() { return this._password; });
/** * Virtual getters */ userSchema.virtual('photo').get(function () { return fbManager.buildUserPhotoUrl(this.fb_id); });
CommentSchema.virtual('image') .set(function(image) { this._image = image; }) .get(function () { return this._image; });
schema.virtual('isTicket').get(function() { if (this.Product_Group=='TICKET') { return true; } return false; });
User.virtual('password') .set(function(password) { this._password = password; this.salt = this.makeSalt(); this.hashedPassword = this.encryptPassword(password); }) .get(function() { return this._password; });
/** * Is this post a thread-starting. * @name isOp * @type {Boolean} * @memberOf module:models/post~Post * @instance * @readOnly */ postSchema.virtual('isOp').get(function () { return this.__t === 'Thread'; });
/** * Sequential number of parent thread unique to thread's board. * @type {Int32} * @memberOf module:models/post~Thread * @instance * @readOnly */ threadSchema.virtual('threadId').get(function() { return this.postId; });