These are chat archives for Automattic/mongoose

14th
Sep 2017
Vineet Dev
@devin6391
Sep 14 2017 07:29
Hi, I am new to mongoose and learning mongo Db. I need to know if I can create two different models to same collection with different schemas?
Scott Gilroy
@sgilroy
Sep 14 2017 17:45
@devin6391 I believe you could use the collection parameter of the mongoose.model() method http://mongoosejs.com/docs/api.html#index_Mongoose-model to create multiple models using the same collection. However, this this not typical and probably not recommended as it would be easy to corrupt your data or create various runtime problems if you do this.
mongoose.model('Actor', new Schema({ name: String, role: String }), 'people');
mongoose.model('Director', new Schema({ name: String, assistant: String }), 'people');