$rtrim

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

Reference group: String aggregation expressions

What it does

Removes specified characters from the end.

Syntax

{$rtrim: { input, chars? }}

Use case

Remove trailing padding.

$rtrim: practical example
{ $project: { clean: { $rtrim: { input: "$rawCode" } } } }
💡 Explanation Removes specified characters from the end. When to use it Remove trailing padding.
Key Takeaways
  • Removes specified characters from the end.
  • Typical use: Remove trailing padding.