Skip to content
tutorial

Filter Entities ​

Query Entities ​

json
{
  "where": {
    "age": 30
  }
}

Use the where clause in your request body to retrieve a specific subset of entities. The filtering syntax follows the Drizzle Relation Query (RQB) pattern, allowing you to use logical operators and comparison methods to build complex queries.

CategoryOperatorDescription
LogicalAND, OR, NOTCombine multiple filter conditions.
Comparisoneq, ne, gt, gte, lt, lteEquality and comparison operators.
Inclusionin, notInCheck if a value exists within an array.
Stringlike, ilike, notLike, notIlikeCase-sensitive and case-insensitive pattern matching.
NullityisNull, isNotNullCheck if a column is null or contains a value.
ArrayarrayOverlaps, arrayContained, arrayContainsSpecialized filters for array column types.
[Full Syntax Schema]

Use this schema to construct nested queries. Refer to the API reference and Entities for specific field names and valid values.

{
  "where": {
    "relation_name": {},
    "column_name": {
      "OR": [],
      "AND": [],
      "NOT": {},
      "eq": 1,
      "ne": 1,
      "gt": 1,
      "gte": 1,
      "lt": 1,
      "lte": 1,
      "in": [1],
      "notIn": [1],
      "like": "",
      "ilike": "",
      "notLike": "",
      "notIlike": "",
      "isNull": true,
      "isNotNull": true,
      "arrayOverlaps": [1, 2],
      "arrayContained": [1, 2],
      "arrayContains": [1, 2]
    }
  }
}

Paginate Results ​

Control the size of your result set using these parameters:

ParameterTypeDefaultDescription
pageinteger0The zero-based index of the current page.
page_sizeinteger25The maximum number of items returned per page.

The server returns your requested data alongside pagination metadata:

ts
{
    items: Array<T>,          // The list of records matching the query
    page: number,             // The zero-based index of the current page
    page_size: number,        // Items per page
    total: number,            // Total records in the database (ignoring filters)
    total_filtered: number,   // Total records matching your filter criteria
}

Subscribe to Live Updates ​

Subscribe via Socket.io to receive real-time updates for an entity.

When you subscribe, the server sends an initial list of entities matching your criteria. If a record is added, modified, or removed in a way that affects your filters, the server automatically pushes the updated list via the baseline.filter.list event.

WARNING

Pagination settings (page and page_size) still apply to live filtered streams.

Use the Baseline Client ​

The baseline-client library simplifies implementation by handling request construction for you.

Fetch a Static List ​

js
const todos = await baseline.api.list("todos");

Listen to a Live Filtered List ​

js
const todos = baseline.api.liveList("todos", {
    where: {
        title: {
            like: "example%"
        }
    },
    page_size: 10
});