Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to add integer and boolean type #10

Closed
ropi95 opened this issue Aug 6, 2019 · 1 comment
Closed

How to add integer and boolean type #10

ropi95 opened this issue Aug 6, 2019 · 1 comment

Comments

@ropi95
Copy link

ropi95 commented Aug 6, 2019

how to set datatype to integer and boolean validator

@coldze
Copy link
Owner

coldze commented Aug 7, 2019

Hi @ropi95,

For insert operation it looks like this:

{
  "insert": "test",
  "documents": [
    {
      "bool_val" : false,
      "int32_type" : {
        "$numberInt": "2"
      },
      "int64_type" : {
        "$numberLong": "2"
      }
    }
  ]
}

Please, refer to documentation for other data types.

For validators one have to specify bson-types:

{
  "collMod": "test",
  "validator": {
    "$jsonSchema": {
      "bsonType": "object",
      "required": [
        "bool_val",
        "int32_type",
        "int64_type",
      ],
      "properties": {
        "bool_val": {
          "bsonType": "bool",
          "description": "bool_val is required and should be of boolean type"
        },
        "int32_type": {
          "bsonType": "int",
          "description": "int32_type is required and should be of integer32 type"
        },
        "int64_type": {
          "bsonType": "long",
          "description": "int64_type is required and should be of integer64 type"
        }
      }
    }
  },
  "validationAction": "error",
  "validationLevel": "strict"
}

@coldze coldze closed this as completed Aug 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants