[SERVER-20718] $type should take an array of types to match against Created: 01/Oct/15 Updated: 06/Dec/22 Resolved: 29/Aug/17 |
|
| Status: | Closed |
| Project: | Core Server |
| Component/s: | Querying |
| Affects Version/s: | None |
| Fix Version/s: | None |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | David Golden | Assignee: | Backlog - Query Team (Inactive) |
| Resolution: | Duplicate | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Issue Links: |
|
||||||||||||||||
| Assigned Teams: |
Query
|
||||||||||||||||
| Participants: | |||||||||||||||||
| Description |
|
For document validation to allow multiple acceptable types for a field, one must nest a verbose $or expression in the validator like this:
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:
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). |
| Comments |
| Comment by David Storch [ 29/Aug/17 ] |
|
This was implemented in |
| Comment by David Storch [ 26/Oct/15 ] |
|
We would like to keep the predicate language small. Instead of adding $or-like functionality to $type, we think it makes sense to require use of $or. Closing as Won't Fix. |