How to use the modelSchemas function from mongoose

Find comprehensive JavaScript mongoose.modelSchemas code examples handpicked from public code repositorys.

85
86
87
88
89
90
91
92
93
94
## mongoose basics

> * your models extends from mongoose.Model
> * schemas are stored on global mongoose but models may not
> * mongoose.models.ModelName equals to mongoose.model('ModelName')
> * ModelName.schema equals to mongoose.modelSchemas.ModelName
> * static methods should be extended on mongoose.Model with a dynamic context
> * instance methods should be extended on mongoose.Model.prototype
> * custom model static methods are stored in MyModel.schema.statics 
> * connection instance store its own models 
fork icon7
star icon48
watch icon6

+ 11 other calls in file

90
91
92
93
94
95
96
97
    }
};

// Export model
delete mongoose.models.SurveyResponse
delete mongoose.modelSchemas.SurveyResponse
var SurveyResponse = mongoose.model('SurveyResponse', SurveyResponseSchema);
module.exports = SurveyResponse;
fork icon29
star icon38
watch icon24