$type should take an array of types to match against

XMLWordPrintableJSON

    • Type: Improvement
    • Resolution: Duplicate
    • Priority: Major - P3
    • None
    • Affects Version/s: None
    • Component/s: Querying
    • None
    • Query
    • None
    • 3
    • None
    • None
    • None
    • None
    • None
    • None

      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).

            Assignee:
            Backlog - Query Team (Inactive)
            Reporter:
            David Golden
            Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

              Created:
              Updated:
              Resolved: