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
let mongoose = require('mongoose'); | |
let {ObjectId, Array: SchemaArray} = mongoose.SchemaTypes; | |
// method for doing the path extension | |
function addIdsMethod (schema, pathname) { | |
let path = schema.paths[pathname], | |
defaultValue = path.defaultValue, | |
cast = SchemaArray.prototype.cast; | |
// convenience method for extending the result of an arbitrary method, applied to "this" |