Home:ALL Converter>MongoDB - Cannot create json schema with INTEGER

MongoDB - Cannot create json schema with INTEGER

Ask Time:2022-07-28T19:01:33         Author:Codrin Sirboiu

Json Formatter

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. enter image description here

Author:Codrin Sirboiu,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/73151789/mongodb-cannot-create-json-schema-with-integer
yy