-
-
Couldn't load subscription status.
- Fork 3.9k
Closed
Milestone
Description
For example, the logic here does not use options object passed to the constructor and therefore options cannot be configured on new instances without having to manually call .set('some', 'value);.
Lines 60 to 94 in 61f698c
| function Mongoose(options) { | |
| this.connections = []; | |
| this.models = {}; | |
| this.modelSchemas = {}; | |
| // default global options | |
| this.options = { | |
| pluralization: true | |
| }; | |
| const conn = this.createConnection(); // default connection | |
| conn.models = this.models; | |
| this._pluralize = legacyPluralize; | |
| // If a user creates their own Mongoose instance, give them a separate copy | |
| // of the `Schema` constructor so they get separate custom types. (gh-6933) | |
| if (!options || !options[defaultMongooseSymbol]) { | |
| const _this = this; | |
| this.Schema = function() { | |
| this.base = _this; | |
| return Schema.apply(this, arguments); | |
| }; | |
| this.Schema.prototype = Object.create(Schema.prototype); | |
| Object.assign(this.Schema, Schema); | |
| this.Schema.base = this; | |
| this.Schema.Types = Object.assign({}, Schema.Types); | |
| } else { | |
| // Hack to work around babel's strange behavior with | |
| // `import mongoose, { Schema } from 'mongoose'`. Because `Schema` is not | |
| // an own property of a Mongoose global, Schema will be undefined. See gh-5648 | |
| for (const key of ['Schema', 'model']) { | |
| this[key] = Mongoose.prototype[key]; | |
| } | |
| } | |
| this.Schema.prototype.base = this; |
Metadata
Metadata
Assignees
Labels
No labels