$toBool
Reference group: Conversion and type inspection
What it does
Converts supported values to boolean.
Syntax
{$toBool: expression}
Use case
Normalize boolean-like BSON values.
Important notes
Text false may convert to true as a non-empty string; explicitly map textual flags.
$toBool: practical example
{ $project: { flag: { $toBool: "$enabledValue" } } }💡 Explanation
Converts supported values to boolean.
When to use it
Normalize boolean-like BSON values.
Caution
Text
false may convert to true as a non-empty string; explicitly map textual flags.Key Takeaways
- Converts supported values to boolean.
- Typical use: Normalize boolean-like BSON values.