$mod

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

Reference group: Arithmetic expressions

What it does

Returns the remainder.

Syntax

{$mod: [number, divisor]}

Use case

Parity checks and cycle assignment.

$mod: practical example
{ $project: { remainder: { $mod: ["$sequence", 2] } } }
💡 Explanation Returns the remainder. When to use it Parity checks and cycle assignment.
Key Takeaways
  • Returns the remainder.
  • Typical use: Parity checks and cycle assignment.