Skip to content

$toInt

Converts a value to a 32-bit integer, truncating toward zero.

Syntax

{ "$toInt": <expression> }

Example

Input

{ "quantity": "15" }

Stage

{ "$project": { "quantity": { "$toInt": "$quantity" } } }

Output

{ "quantity": 15 }