I have these valdation rules for my collection:
"$jsonSchema": {
"bsonType": "object",
"required": ["CCF_CNAME", "CCF_NPARS"],
"properties": {
"CCF_CNAME": {
"bsonType": "string",
"uniqueItems": true,
"description": "CCF_CNAME must be a unique string."
},
"CCF_NPARS": {
"bsonType": "int",
"description": "CCF_NPARS must be an integer."
}
}
}
}
but for some reason when I try to insert a document with a CCF_CNAME string that already exists, I don’t get an error…
For example I insert these two rows:
“POWER_ON” 1
“POWER_ON” 2
the string is the same, but no error. I ran the command
db.getCollectionInfos( { name: "ccf" } )[0].options.validator
and I got my validation correctly, so that’s not the problem. Also trying to use a CCF_NPARS value that is a float for example does give an error.
What am I missing?