Reputation: 33
I am trying to create a collection with a json schema for validation. I got stuck on the following error and couldn't find anything related to it. I managed to create the schema using number type, but integer seems to throw this error.
Using mongodb-driver-sync and mongodb-driver-legacy v4.2.3
Caused by: com.mongodb.MongoCommandException: Command failed with error 9 (FailedToParse): '$jsonSchema type 'integer' is not currently supported.' on server 127.0.0.1:27017. The full response is {"ok": 0.0, "errmsg": "$jsonSchema type 'integer' is not currently supported.", "code": 9, "codeName": "FailedToParse"}
Tried changing the json schema from Compass and I'm getting the same error, so the problem is definitely coming from the database, not the driver.
Upvotes: 2
Views: 572
Reputation: 13500
MongoDB's JSONSchema doesn't, per the documentation, support Integer
.
Omissions
The following are not supported in MongoDB's implementation of JSON Schema:
- The integer type. You must use the BSON type
int
orlong
with thebsonType
keyword.
createTime: {
bsonType: "int"
}
Upvotes: 1