Last active
January 14, 2019 14:06
-
-
Save melvinkcx/3d0da32ab10a55cb7b5e0d67f67fdb18 to your computer and use it in GitHub Desktop.
Dive Into The Performance of mongoose-lean-virtuals - A Mongoose Plugin That Enables Virtuals in Lean Mode
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Full Repo: https://bitbucket.org/melvinkcx/mongoose_lean_virtuals_profiler/src/master/ | |
const mongoose = require('mongoose'); | |
const mongooseLeanVirtuals = require('mongoose-lean-virtuals'); | |
const Schema = mongoose.Schema; | |
// Modelled after imdb title dataset | |
// Link: https://datasets.imdbws.com/title.basics.tsv.gz | |
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; | |
}); | |
titleSchema.plugin(mongooseLeanVirtuals); | |
module.exports = titleSchema; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment