有没有一种方法可以使文档数组中的值对文档唯一

时间:2019-06-05 03:28:35

标签: mongodb mongoose

我有这个(简化的)模式:

{
  name: {type:String, unique: true}
  idList: [String]
}

我希望idList中的值在整个集合中都是唯一的

我看过mongoose-unique-array,但它似乎仅支持数组中的唯一值。

我是否需要制作idList的另一个收藏并将其链接回id?

0 个答案:

没有答案
相关问题