简体   繁体   English

在猫鼬中映射多对多关系的最佳方法是什么

[英]What is the best way to map a Many to Many relationship in mongoose

I am building an immunization tracker.我正在构建一个免疫跟踪器。 There are 2 models:有2种型号:

  1. patient病人
  2. vaccine疫苗

Each patient should have a set of vaccines which can be modified.每个患者都应该有一套可以修改的疫苗。

Based on Mongo Blog for relationships best way of representing sql many to many is to keep relation ship array in the parent model (one-to-many approach with reference id) and use that array to for both way data joining.基于 Mongo 博客的关系,表示多对多 sql 的最佳方式是将关系数组保留在父模型中(​​具有参考 ID 的一对多方法),并使用该数组进行双向数据连接。

https://docs.mongodb.com/manual/tutorial/model-referenced-one-to-many-relationships-between-documents/ https://docs.mongodb.com/manual/tutorial/model-referenced-one-to-many-relationships-between-documents/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM