|
Currently $jsonSchema will treat a property as required if the schema specifies a type. The JSON Schema spec, however, says to permit the property to be missing in this case.
> db.c.find()
|
{ "_id" : ObjectId("597111d528cdb6d02e838d05"), "a" : 3 }
|
{ "_id" : ObjectId("597111d728cdb6d02e838d06"), "a" : 5 }
|
{ "_id" : ObjectId("597111da28cdb6d02e838d07") }
|
> db.c.find({$jsonSchema: {properties: {a: {type: "number", maximum: 4}}}})
|
{ "_id" : ObjectId("597111d528cdb6d02e838d05"), "a" : 3 }
|
The second query above is missing results, since it should also return the document that does not have the a field.
|