2

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

1 Answer 1

1

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 or long with the bsonType keyword.
createTime: {
    bsonType: "int"
}

Sign up to request clarification or add additional context in comments.

2 Comments

Ah.. thanks. Do you know any object mapper that uses javax annotations to create such a schema?
I don't, sorry!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.