Skip to content

Instantly share code, notes, and snippets.

@melvinkcx melvinkcx/title.model.js
Last active Jan 14, 2019

Embed
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: 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
You can’t perform that action at this time.