$type/$isNumber/$isArray
Reference group: Utility expressions and variables
What it does
Inspects BSON types before applying type-specific operations.
Syntax
Type inspection expressions
Use case
Audit heterogeneous data.
$type/$isNumber/$isArray: practical example
{ $project: { kind: { $type: "$payload" }, isArray: { $isArray: "$items" }, numeric: { $isNumber: "$price" } } }💡 Explanation
Inspects BSON types before applying type-specific operations.
When to use it
Audit heterogeneous data.
Key Takeaways
- Inspects BSON types before applying type-specific operations.
- Typical use: Audit heterogeneous data.