LakeQL
Overview
  • Introduction
Filtering
  • Where Interface
  • Operators
  • Combining Filters
Sorting and Paging
  • Sorting
  • Paging
  • API Reference
GitHub
LakeQL
  1. Query Builder
  2. Filtering
  3. Operators

On this page

  1. Supported Operators
  2. Pattern Matching Examples
  3. Comparison Examples

Operators

All supported filter operators and their SQL translations.

Supported Operators #

The query builder supports a comprehensive set of comparison and pattern-matching operators. Each operator in FieldOptions maps to a specific SQL expression.

OperatorSQL OutputDescription
eq= valueEquals
neq!= valueNot equals
inIN (values)Matches any value in the list
notInNOT IN (values)Does not match any value in the list
lt< valueLess than
lte<= valueLess than or equal
gt> valueGreater than
gte>= valueGreater than or equal
likeLIKE '%value%'Contains (wraps value with wildcards)
notLikeNOT LIKE '%value%'Does not contain
startsWithLIKE 'value%'Starts with the given prefix
notStartsWithNOT LIKE 'value%'Does not start with the given prefix
endsWithLIKE '%value'Ends with the given suffix
notEndsWithNOT LIKE '%value'Does not end with the given suffix
is= valueEquality check (typically for booleans)
isNot!= valueInequality check (typically for booleans)

Pattern Matching Examples #

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20import type { Where } from "@lakeql/query-builder"

// Contains "smith" anywhere in the name
const containsFilter: Where = {
  and: [{ name: { like: "smith" } }],
}
// SQL: WHERE "name" LIKE '%smith%'

// Starts with "prod-"
const prefixFilter: Where = {
  and: [{ environment: { startsWith: "prod-" } }],
}
// SQL: WHERE "environment" LIKE 'prod-%'

// Ends with ".csv"
const suffixFilter: Where = {
  and: [{ filename: { endsWith: ".csv" } }],
}
// SQL: WHERE "filename" LIKE '%.csv'

Comparison Examples #

1
2
3
4
5
6
7
8
9
10
11
12
13
14
import type { Where } from "@lakeql/query-builder"

// Numeric range
const rangeFilter: Where = {
  and: [{ price: { gte: "10" } }, { price: { lte: "100" } }],
}
// SQL: WHERE "price" >= '10' AND "price" <= '100'

// Membership
const membershipFilter: Where = {
  and: [{ status: { in: ["active", "pending"] } }],
}
// SQL: WHERE "status" IN ('active', 'pending')

Previous page

Where Interface

Next page

Combining Filters

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20