Reputation: 5200
Can Mongo IDs have the same value in different collections in the same database?
Upvotes: 73
Views: 25709
Reputation: 2115
The uniqueness constraint for _id is per collection, so yes - one and the same ID can occur once per Collection.
It's however very unlikely, if not impossible, for the same ID to be generated twice. So in order for this to happen you would have to manually insert duplicate IDs.
Upvotes: 79