Mongoose subdocuments vs nested schema

后端 未结 6 1019
萌比男神i
萌比男神i 2020-11-29 17:59

I\'m curious as to the pros and cons of using subdocuments vs a deeper layer in my main schema:

var subDoc = new Schema({
  name: String
});

var mainDoc = n         


        
6条回答
  •  我在风中等你
    2020-11-29 18:28

    If you have schemas that are re-used in various parts of your model, then it might be useful to define individual schemas for the child docs so you don't have to duplicate yourself.

提交回复
热议问题