0

I have this (simplified) schema:

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

I would like values in idList to be unique in the whole collection

I have looked at mongoose-unique-array and but it seems to only support unique values only within the array.

Do I need to to make the idList another collection and link it back with id?

Manish Balodia
  • 1,863
  • 2
  • 23
  • 37
  • Please Check [Mongo schema, array of string with unique values](https://stackoverflow.com/questions/41788688/mongo-schema-array-of-string-with-unique-values) – saketh Jun 05 '19 at 04:50
  • I am looking to have the value be unique across other arrays in entries in the document too, beyond just the array itself. – Zheng Chen Jun 05 '19 at 17:50

0 Answers0