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|ed75e748-c173-4d56-8376-b780c4364b40|:m{
                s|num|:n|5|,
                s|name|:s|test_5|,
            },
            test|b89c8f7f-858e-487c-b134-ef1b7a1060dc|:m{
                s|name|:s|test_9|,
                s|num|:n|9|,
            },
            test|dfc92830-68e0-4d78-b4c1-f821f570eb9a|:m{
                s|name|:s|test_6|,
                s|num|:n|6|,
            },
            test|31364c30-110d-47f5-9ad7-1e378b05b63b|:m{
                s|num|:n|7|,
                s|name|:s|test_7|,
            },
            test|74b7fbcc-e681-45f7-a1e2-76b6b8c379f7|:m{
                s|name|:s|test_8|,
                s|num|:n|8|,
            },
        },
        s|meta|:find_meta{
            s|count|:n|5|,
        },
    },
];