| Steps To Reproduce: |
Create collection:
db.getCollection("types").insert({
|
"domainId": "type",
|
});
|
db.getCollection("types").insert({
|
"domainId": "view",
|
});
|
db.getCollection("types").insert({
|
"domainId": "vfsdata",
|
"namespace": "eportal",
|
});
|
db.getCollection("types").insert({
|
"domainId": "admin",
|
"namespace": "eportal",
|
});
|
Test query:
db.types.find( { "$or" : [ { "namespace" : "eportal"} , { "namespace" : null }] } )
|
{ "_id" : ObjectId("538602b59b6fe0b5efcf8c13"), "domainId" : "type" }
|
{ "_id" : ObjectId("538602b59b6fe0b5efcf8c14"), "domainId" : "view" }
|
{ "_id" : ObjectId("538602b59b6fe0b5efcf8c15"), "domainId" : "vfsdata", "namespace" : "eportal" }
|
{ "_id" : ObjectId("538602b59b6fe0b5efcf8c16"), "domainId" : "admin", "namespace" : "eportal" }
|
Add index:
db.types.ensureIndex( { namespace: 1, domainId: 1 }, { unique: 1 } )
|
Test query again:
db.types.find( { "$or" : [ { "namespace" : "eportal"} , { "namespace" : null }] } )
|
{ "_id" : ObjectId("538602b59b6fe0b5efcf8c13"), "domainId" : "type" }
|
{ "_id" : ObjectId("538602b59b6fe0b5efcf8c14"), "domainId" : "view" }
|
|