Skip to content

Find

Find objects using comparison and logical operators

Prefix: find

Value: Vector of operators

Can start the pipeline: Yes

Steps before: find, get, sort, limit, offset

Steps after: find, get, sort, limit, offset, update, delete

Comparison operators

  • Equal - eq{...}
  • Not equal - neq{...}
  • Greater than - gt{...}
  • Greater than or equeal - gte{...}
  • Less than - lt{...}
  • Less than or equal - lte{...}
  • Less than or equal - lte{...}

Logical operators

  • And - and[...]
  • Or - or[...]
  • Not - not(...)

In order to compare the value of the object root path notation could be used:

eq{root: s|bar|}

In order to compare a field of the object path to value notation could be used:

eq{value|path.to.field|: s|bar|}

Example

Input:

collection|test|:find[
    gt{
        value|num|:n|4|,
    },
];

Output:

result:ok[
    response{
        s|data|:objects{
            test|0b2e4900-65d3-4ab6-ab6d-0990f8e1e1e5|:m{
                s|name|:s|test_9|,
                s|num|:n|9|,
            },
            test|6dfa4b74-54e9-44b9-978e-4310a1954da1|:m{
                s|num|:n|5|,
                s|name|:s|test_5|,
            },
            test|ebeb0680-c392-483a-b8fe-735a4ae55758|:m{
                s|num|:n|6|,
                s|name|:s|test_6|,
            },
            test|fabe4666-8ab9-48bd-a5cf-0c3fe9f67164|:m{
                s|num|:n|7|,
                s|name|:s|test_7|,
            },
            test|a681ed05-582a-43db-9e92-bc76c8919977|:m{
                s|num|:n|8|,
                s|name|:s|test_8|,
            },
        },
        s|meta|:find_meta{
            s|count|:n|5|,
        },
    },
];