Reputation: 5885
I have collection of documents, witch has an array, of embedded documents, how i can setup unique key on a field in these array?
example collection
{
field:1
field2: [
{field3:1, field4:4},
{field3:1, field4:5},
]
}
i would like to ensure that "field4" of array "field2" is unique across all documents in collection?
Upvotes: 0
Views: 75
Reputation: 81
You would need a separate collection holding field4 values, which would act as an index.
Upvotes: 1