$toBool
Converts a value to a boolean using MongoDB’s truthiness rules.
Syntax
{ "$toBool": <expression> }
Example
Input
{ "flag": "true" }
Stage
{ "$project": { "asBoolean": { "$toBool": "$flag" } } }
Output
{ "asBoolean": true }
Converts a value to a boolean using MongoDB’s truthiness rules.
{ "$toBool": <expression> }
{ "flag": "true" }
{ "$project": { "asBoolean": { "$toBool": "$flag" } } }
{ "asBoolean": true }