$toDouble

Reference type:Cheat sheetFormat:Syntax + example + use case

Reference group: Conversion and type inspection

What it does

Converts compatible values to double precision.

Syntax

{$toDouble: expression}

Use case

Normalize numeric strings where floating-point semantics are acceptable.

$toDouble: practical example
{ $set: { score: { $toDouble: "$scoreText" } } }
💡 Explanation Converts compatible values to double precision. When to use it Normalize numeric strings where floating-point semantics are acceptable.
Key Takeaways
  • Converts compatible values to double precision.
  • Typical use: Normalize numeric strings where floating-point semantics are acceptable.