$indexOfBytes

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

Reference group: String aggregation expressions

What it does

Returns byte index of a substring.

Syntax

{$indexOfBytes: [string, substring, start?, end?]}

Use case

Parse byte-oriented formats.

$indexOfBytes: practical example
{ $project: { at: { $indexOfBytes: ["$code", "-"] } } }
💡 Explanation Returns byte index of a substring. When to use it Parse byte-oriented formats.
Key Takeaways
  • Returns byte index of a substring.
  • Typical use: Parse byte-oriented formats.