$type
Reference group: Conversion and type inspection
What it does
Returns BSON type name; aggregation can report missing for an absent field.
Syntax
{$type: expression}
Use case
Audit mixed-type data.
$type: practical example
{ $project: { fieldType: { $type: "$price" } } }💡 Explanation
Returns BSON type name; aggregation can report
missing for an absent field.
When to use it
Audit mixed-type data.Key Takeaways
- Returns BSON type name; aggregation can report
missingfor an absent field. - Typical use: Audit mixed-type data.