Skip to content

Instantly share code, notes, and snippets.

Last active Jan 14, 2019
What would you like to do?
Dive Into The Performance of mongoose-lean-virtuals - A Mongoose Plugin That Enables Virtuals in Lean Mode
// Full Repo:
const mongoose = require('mongoose');
const mongooseLeanVirtuals = require('mongoose-lean-virtuals');
const Schema = mongoose.Schema;
// Modelled after imdb title dataset
// Link:
const titleSchema = new Schema({
genres: String,
runtimeMinutes: Number,
endYear: String,
startYear: String,
isAdult: Number,
originalTitle: String,
primaryTitle: String,
tconst: String,
titleType: String
}, {
collection: 'title_basic'
titleSchema.virtual('isLong').get(function() {
return this.runtimeMinutes ? this.runtimeMinutes > 30 : null;
module.exports = titleSchema;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment