Using the following mongoose schema
mongoose.Schema({
world: String,
color: [{ name: String }]
});
Gives me document that have sub-documents containing _id
fields.
{ _id: 'a9ec8475bf0d285e10ca8d42'
world: 'matrix',
color: [
{ name: 'blue', _id: '4a8c0e12135fa32e13db9ce9' },
{ name: 'red', _id: '4a8c0a62254cd32e13db4ad8' },
{ name: 'white', _id: '4a8c04e2687ea32e13db1da7' }
]
I want to know if each of these sub-documents _id
are unique across all documents, or only across the nested level it is in.
Edit: the sub-document doesn't refer to another collection, it's created with the plain mongoose schema above.