-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: None
-
Component/s: Querying
-
None
-
Query
For document validation to allow multiple acceptable types for a field, one must nest a verbose $or expression in the validator like this:
{ "$or" : [ { "views" : { "$type" : 16 } }, { "views" : { "$type" : 18 } } ] }
It would be much easier to use $type if it could optionally take an array, which would be treated like $in and match any of the elements of the array.
The expression above would thus simplify to this:
{ "views" : { "$type" : [16, 18] } }
When such multi-type constraints have to be applied to many fields, validators would be much more succinct, making them easier to write (and read).
- duplicates
-
SERVER-30245 Extend JSON Schema parser to handle the type keyword containing an array of types
- Closed
- is related to
-
SERVER-30191 Add JSON Schema support for document validation
- Closed