mongoose-util
Small collection of opinionated helper functions for working with mongoose
VersionIncrementor class
Sets up the $inc: { versionKey: 1 } in a consistant way on an update clause.
var mongoose = mongooseUtil = ; var versionIncrementor = '_version' ; var userSchema = firstName: String lastName: String versionKey: versionIncrementorversionKey; // setup the update clause and $inc: { _version: 1 } propertyvar updateClause = firstName: 'Jimmy' ;versionIncrementor; var userModel = mongoose;userModel;
rawDoc( response ) function
Returns only the raw document, instead of the rich Model object.
var mongoose = mongooseUtil = ; var userSchema = firstName: String lastName: String versionKey: versionIncrementorversionKey; var userModel = mongoose; return userModel ;