Skip to content

$join

Takes an array array and a separator string sep and joins the elements of the array (each cast to string) separated by sep.

Options

  • array (required) Array of values to be joined.
  • sep (optional) Separator string. Default '' (empty string).

Example

{
    "code": {
        "$join": {
            "array": ["foo", "bar", "baz"],
            "sep": "-"
        }
    }
}
{
    "code": "foo-bar-baz"
}