Foreign keys in mongo?

前端 未结 5 1130
渐次进展
渐次进展 2020-12-12 17:16

\"enter

How do I design a scheme such this in MongoDB? I think there are no foreign ke

5条回答
  •  一个人的身影
    2020-12-12 17:22

    The purpose of ForeignKey is to prevent the creation of data if the field value does not match its ForeignKey. To accomplish this in MongoDB, we use Schema middlewares that ensure the data consistency.

    Please have a look at the documentation. https://mongoosejs.com/docs/middleware.html#pre

提交回复
热议问题