Crate jsonutil

Source
Expand description

Library to handle JSON schema and BSON schema types

Document validation on MongoDB uses an hybrid form of JSON schema and BSON schema to implement runtime validation of data inserted/updated on a database collection.

JSON schema is too limited to express all database native types which are thus expressed by BSON types. MongoDB allows to define data schema and validation, when possible, as JSON type using the key type and enhance with the key bsonType. Thus there are 3 forms to read validations from MongoDB

BSON types are mapped onto JSON types using the following table:

BSON TypebsonTypetypeJSON type
Double“double”“number”Number
String“string”“string”String
Object“object”“object”Object
Array“array”“array”Array
Binary Data“binData”--
ObjectId“objectId”--
Boolean“bool”“boolean”Boolean
Date“date”--
Null“null”“null”Null
Regular Expression“regex”--
JavaScript“javascript”--
32-bit Signed Integer“int”“integer”Integer
64-bit Signed Integer“long”“integer”Integer
Timestamp“timestamp”--
128-bit Decimal Float“decimal”“number”Number
Min Key“minKey”--
Max Key“maxKey”--

Modules§

bson
This module contains the BSON schema typings used to express a validation on MongoDB like the following:
json
This module contains the Draft-04 JSON schema typings
mongodb
This module contains the hybrid BSON + JSON schema typings used to express a validation on MongoDB like the following: