Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我想问一下 Mongoose 中是否可以在模式中有一个具有多个引用的字段。例如。如果我们有一个角色字段引用指定该角色的其他模型。
喜欢用户 - 参考 -> 学生/老师。
不。mongo 是 no-rel db,mongoose 所做的是使用字段数据中提供的 id 查询您在 ref 中指定的模型。
因此,在 mongo 中,refs 基本上是不好的做法(当然默认情况下)。