How to declare collection name and model name in mongoose

后端 未结 4 1503
死守一世寂寞
死守一世寂寞 2021-02-02 18:26

I have 3 kind of records,

1)Categories,
2)Topics  and
3)Articles 

In my mongodb, i have only 1 colection named \'categories\' in which i stroe

4条回答
  •  礼貌的吻别
    2021-02-02 19:08

    You can use Mongoose Discriminators (http://mongoosejs.com/docs/discriminators.html) for that.

    This article has a good and easy example of how to do that: https://docs.microsoft.com/en-us/azure/cosmos-db/mongodb-mongoose#using-mongoose-discriminators-to-store-data-in-a-single-collection.

提交回复
热议问题