Filter Operators Reference

Operator reference

OperatorExampleSQL semantics
equals{id: {equals: 10}}=
not{status: {not: "DELETED"}}!=
in{status: {'in: ["ACTIVE", "PENDING"]}}IN (...)
notIn{role: {notIn: ["BANNED"]}}NOT IN (...)
lt{age: {lt: 18}}<
lte{age: {lte: 65}}<=
gt{score: {gt: 80}}>
gte{score: {gte: 80}}>=
contains{email: {contains: "@example.com"}}LIKE '%...%'
startsWith{name: {startsWith: "A"}}LIKE 'A%'
endsWith{name: {endsWith: "son"}}LIKE '%son'
isNull{deletedAt: {isNull: true}}IS NULL / IS NOT NULL

Logical operators

OperatorExampleSQL semantics
AND{AND: [{...}, {...}]}conjunction
OR{OR: [{...}, {...}]}disjunction
NOT{NOT: {...}}negation

Nested example

ballerina
var rows = check db.'from(User)
    .'where({
        AND: [
            {status: {equals: "ACTIVE"}},
            {age: {gte: 18}}
        ],
        OR: [
            {email: {endsWith: "@example.com"}},
            {email: {endsWith: "@test.com"}}
        ],
        NOT: {
            role: {equals: "BANNED"}
        }
    })
    .findMany();