For the complete documentation index, see llms.txt. This page is also available as Markdown.

Collections

Use jet.collection(resourceName, collectionName) to access records from a configured resource. Examples assume an authenticated jet client from Getting started. Replace sample collection fields with your own schema.

List and filter

import { Jet, QueryLookup } from '@jet-admin/jet-sdk';

async function listActiveCustomers(jet: Jet) {
  const page = await jet.collection('YOUR_RESOURCE', 'customers').list({
    filters: [
      { field: 'status', lookup: QueryLookup.Exact, value: 'active' },
      { field: 'name', lookup: QueryLookup.IContains, value: 'alex' },
    ],
    pagination: { page: 1, perPage: 25 },
    orderBy: { field: 'created_at', desc: true },
  });
  return { rows: page.results.map(record => record.data), hasMore: page.hasMore };
}

list() also accepts search: string for the resource's search behavior. Searchable fields and supported lookup behavior depend on the resource.

Option
Sent to the API

pagination.page

page

pagination.perPage

_per_page

orderBy.field

_order_by; prefixed with - when desc is true

search

_search

filters

One query parameter per field/lookup combination

The SDK supplies no pagination defaults and does not follow pages automatically. Start with page 1 where supported by your resource API. The response contains results: CollectionRecord[], optional hasMore, and optional count. API next and previous links are not exposed. Use the resource API's pagination contract if hasMore is absent; do not treat an absent value as a guaranteed last page.

Filter lookups

Enum member
Wire suffix
Intended use, where supported by the resource

Exact

No suffix

Equality

Gt, Gte, Lt, Lte

gt, gte, lt, lte

Comparisons

In

in

Membership

IContains

icontains

Case-insensitive containment

IStartsWith, IEndsWith

istartswith, iendswith

Case-insensitive prefix/suffix

IsNull, IsEmpty

isnull, isempty

Null/empty checks

CoveredBy

coveredby

Resource-specific coverage lookup

JsonIContains

json_icontains

Resource-specific JSON containment

Nonempty lookups are joined with a single underscore: age_gte, for example. Equality sends only the field name. Values are stringified; dates become ISO strings, objects become JSON strings, arrays remain arrays of converted values, and undefined is omitted. Axios handles array query serialization. Confirm the resource's expected format for membership filters.

Two filters with the same field and lookup overwrite the same query parameter; the last value wins. There is no SDK OR-group builder.

Get, create, update, and delete

The functions below are separate examples; call only the operation your UI intends to perform.

Method
Required options
Returns

getOne

primaryKey: string

CollectionRecord

create

data: Record<string, unknown>

CollectionRecord

update

primaryKey, data; optional fields: string[]

CollectionRecord

delete

primaryKey, record: CollectionRecord; optional fields

void

update() sends PATCH. With fields, it picks only those keys from data; otherwise it sends all supplied data. This is not a returned-field selection.

The current TypeScript signature requires record for deletion, although the implementation uses only primaryKey. Its optional fields value is also ignored. Deletion removes the record; it does not delete selected fields.

Resource names, collection names, and primary keys are interpolated directly into URLs. Use identifiers matching your API's path format.

Scope

This version has no collection methods for aggregate, group, raw SQL, bulk edits, or resource reload. Those REST endpoints may exist independently; do not call invented methods such as collection.aggregate().

Was this helpful?