Skip to content

$arrayFilter

$arrayFilter will check whether a element in the array equals the query and return it.

Usage

$arrayFilter[name;query;queryType?;separator?]

Parameters

FieldTypeDescriptionRequired
namestringArray name.true
querystringThe element we will be querying for every element inside the array.true
queryType?stringThe comparison operator.false
separator?stringSeparator.false

Comparison Operators

  • == — Every item that matches the query.
  • != — Every item that doesn’t match the query.
  • > — All items on the “left” of the found item, excluding itself.
  • < — All items on the “right” of the found item, excluding itself.
  • >= — All items on the “left” of the found item, including itself.
  • <= — All items on the “right” of the found item, including itself.

Example(s)

1
client.command({
2
name: "array-filter",
3
code: `
4
$arrayFilter[array;akarui;==;, ]
5
$createArray[array;aoi.js;akarui;documents;bot]
6
`
7
// It will return "akarui" as it matches the query.
8
});
1
client.command({
2
name: "array-filter",
3
code: `
4
$arrayFilter[array;akarui;<=;, ]
5
$createArray[array;aoi.js;akarui;documents;bot]
6
`
7
// It will return "documents, bot" as its on the right of the found item.
8
});