-1

Schema:

{
  A: [
   { _id: "string" },
   { _id: "string" },
   { _id: "string" },
   { _id: "string" },
  ]
}

Requirement, the A._id field must be unique for the entire collection, not just unique across the document that it lives.

  {
    "key": {
      "A._id": 1
    },
    "unique": true,
    "partialFilterExpression": {
      "A._id": { "$exists": true }
    }
  }

This did not work

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110

0 Answers0