JavaScript SDK: database reference
Every method of `aura.db` and of the chainable query builder, with its signature.
6 min read·Level reference·Revised on Oct 12, 2026
This English text was generated automatically from the French original and has not been reviewed yet.
#
Class
DatabaseService
| Method | Description |
|---|---|
from<TableName extends string & keyof Schema['Tables'], Table extends Schema['Tables'][TableName]>(table: TableName): AuraQueryBuilder<Schema, Table, TableName, AuraClientOptionsT>from<ViewName extends string & keyof Schema['Views'], View extends Schema['Views'][ViewName]>(view: ViewName): AuraQueryBuilder<Schema, View, ViewName, AuraClientOptionsT>from(table: string): AuraQueryBuilder<any, any, any, AuraClientOptionsT> | Start a query on a table. |
sql<T = unknown>(query: string, params?: unknown[], options?: RawSqlOptions): Promise<AuraResponse<T>> | Executes a raw SQL query (POST /v1/db/raw). |
rpc<FnName extends string, Args extends RpcArgsFor<Schema, FnName> = RpcArgsFor<Schema, FnName>, Fn extends { Row: Record<string, unknown>; Result: unknown; RelationName: unknown; Relationships: unknown; } = RpcResultFor<Schema, FnName, Args>>(fn: FnName, args?: Args, options?: RpcOptions): AuraFilterBuilder<Schema, Fn['Row'], Fn['RelationName'], Fn['Relationships'], Fn['Result'], AuraClientOptionsT> | Calls a function Postgres exposed by PostgREST (POST|GET|HEAD /rpc/{fn}). |
schema(): Promise<AuraResponse<{ tables: SchemaTable[]; functions: SchemaFunction[]; enums: SchemaEnum[]; views: SchemaTable[]; }>> | Fetch the schema (tables & columns, Postgres functions exposed via PostgREST, enum types and views) for the current project. |
listFunctions(): Promise<AuraResponse<PgFunctionInfo[]>> | Lists the functions of the project schema (GET /v1/db/functions). |
createFunction(definition: CreatePgFunctionRequest): Promise<AuraResponse<null>> | Creates or replaces a Postgres (POST /v1/db/functions) function. Requires a service_role key. PostgreSQL projects only. |
dropFunction(name: string): Promise<AuraResponse<null>> | Removes a feature from the project schema (DELETE /v1/db/functions/{name}). Requires a service_role key. |
listTriggers(table: PgRelationName<Schema>): Promise<AuraResponse<PgTriggerInfo[]>> | Lists the triggers of a table (GET /v1/db/{table}/triggers). |
createTrigger(table: PgRelationName<Schema>, definition: CreatePgTriggerRequest): Promise<AuraResponse<null>> | Creates a trigger on a table (POST /v1/db/{table}/triggers). Requires a service_role key. PostgreSQL projects only. |
dropTrigger(table: PgRelationName<Schema>, name: string): Promise<AuraResponse<null>> | Removes a trigger from a table (DELETE /v1/db/{table}/triggers/{name}). Requires service_role. |
#
Class
AuraQueryBuilder
Chainable query builder that compiles to URL query parameters matching the backend's QueryOptions / FilterOp format.
| Method | Description |
|---|---|
insert(body: Relation extends { Insert: infer I; } ? I | I[] : never): this | Inserts a row or an array of rows. |
update(id: string, body: Relation extends { Update: infer U; } ? U : never): AuraFilterBuilder<Schema, Relation['Row'], RelationName, Relation['Relationships'], Relation['Row'][], ClientOptions, false>update(body: Relation extends { Update: infer U; } ? U : never): AuraFilterBuilder<Schema, Relation['Row'], RelationName, Relation['Relationships'], Relation['Row'][], ClientOptions, false> | Updates rows: update(body) targeted by filters, or update(id, body) for one row per identifier. |
delete(id?: string): AuraFilterBuilder<Schema, Relation['Row'], RelationName, Relation['Relationships'], Relation['Row'][], ClientOptions, false> | Deletes rows: targeted by filters, or one row by identifier with delete(id). |
upsert(body: Relation extends { Insert: infer I; } ? I | I[] : never, options?: { onConflict?: string; }): AuraFilterBuilder<Schema, Relation['Row'], RelationName, Relation['Relationships'], Relation['Row'][], ClientOptions, false> | Inserts or updates (upsert) a row or an array of rows. options.onConflict names the conflict column (id by default). |
#
Class
AuraFilterBuilder
All PostgREST filters (eq, neq, ... ilikeAnyOf).
| Method | Description |
|---|---|
eq<C extends keyof Row & string>(column: C, value: Row[C]): this | Filters rows where column equals value. |
neq<C extends keyof Row & string>(column: C, value: Row[C]): this | Filters rows where column is different from value. |
gt<C extends keyof Row & string>(column: C, value: Row[C]): this | Filters rows where column is strictly greater than value. |
gte<C extends keyof Row & string>(column: C, value: Row[C]): this | Filters rows where column is greater than or equal to value. |
lt<C extends keyof Row & string>(column: C, value: Row[C]): this | Filters rows where column is strictly less than value. |
lte<C extends keyof Row & string>(column: C, value: Row[C]): this | Filters rows where column is less than or equal to value. |
like(column: keyof Row & string, pattern: string): this | Filter by pattern LIKE, case sensitive (% replaces a sequence of characters). |
ilike(column: keyof Row & string, pattern: string): this | Filter by pattern ILIKE, case insensitive. |
is(column: keyof Row & string, value: 'null' | 'true' | 'false' | 'unknown' | 'not.null'): this | IS NULL or IS NOT NULL filter. |
in<C extends keyof Row & string>(column: C, values: Row[C][]): this | Filters rows whose column is one of values. |
or(filters: Array<{ column: string; op: string; value: unknown; }>): this | Add an OR group: or=(col1.eq.val1,col2.gt.val2) |
notIn<C extends keyof Row & string>(column: C, values: Row[C][]): this | Filters rows where column is not equal to any of values. |
contains(column: keyof Row & string, value: unknown): this | Filters rows whose column (table, JSON or range) contains value (operator @>). |
containedBy(column: keyof Row & string, value: unknown): this | Filters rows whose column (array, JSON or range) is contained in value (operator <@). |
overlaps(column: keyof Row & string, value: unknown): this | Filters rows whose column (array or range) has at least one element in common with value (operator &&). |
rangeGt(column: keyof Row & string, range: string): this | Interval: filters the ranges located strictly to the right of range (operator >>). |
rangeGte(column: keyof Row & string, range: string): this | Range: Filters ranges that do not extend to the left of range (operator &>). |
rangeLt(column: keyof Row & string, range: string): this | Interval: filters ranges located strictly to the left of range (operator <<). |
rangeLte(column: keyof Row & string, range: string): this | Range: Filters ranges that do not extend to the right of range (operator &<). |
rangeAdjacent(column: keyof Row & string, range: string): this | Range: filters ranges adjacent to range (operator -|-). |
isDistinct(column: keyof Row & string, value: unknown): this | Filters rows where column is distinct from value, treating NULL as a value (IS DISTINCT FROM). |
not(column: string, op: string, value: unknown): this | Negates a filter: not('status', 'eq', 'done') is equivalent to status different from done. |
filter(column: string, op: string, value: unknown): this | Adds a filter with a raw PostgREST operator (eq, gt, cs…), for cases not covered by a dedicated method. |
match(query: Record<string, unknown>): this | Filter by equality on several columns at the same time: match({ a: 1, b: 2 }). |
textSearch(column: keyof Row & string, query: string, options?: { type?: 'plain' | 'phrase' | 'websearch'; config?: string; }): this | Full text search. options.type chooses the query: 'plain', 'phrase' or 'websearch' (otherwise native tsquery syntax); options.config sets the language configuration. |
likeAllOf(column: keyof Row & string, patterns: string[]): this | Filter LIKE: the column must match ALL patterns. |
likeAnyOf(column: keyof Row & string, patterns: string[]): this | Filter LIKE: the column must match AT LEAST ONE of the patterns. |
ilikeAllOf(column: keyof Row & string, patterns: string[]): this | Filter ILIKE (case insensitive): the column must match ALL patterns. |
ilikeAnyOf(column: keyof Row & string, patterns: string[]): this | Filter ILIKE (case insensitive): the column must match AT LEAST ONE of the patterns. |
#
Class
AuraTransformBuilder
Column selection, sorting, pagination and cardinality modifiers (single/maybeSingle/count).
| Method | Description |
|---|---|
select<Query extends string = '*', NewResultOne = GetResult<Schema, Row, RelationName, Relationships, Query, ClientOptions>>(columns?: Query, options?: SelectOptions): AuraFilterBuilder<Schema, Row, RelationName, Relationships, NewResultOne[], ClientOptions, ThrowOnError> | Select columns and optionally embed related resources (PostgREST parity). |
order(column: string, directionOrOptions?: 'asc' | 'desc' | OrderOptions): this | Sort on a column. |
limit(n: number): this | Limits the number of rows returned. |
offset(n: number): this | Ignores the first n rows (shift paging). |
range(from: number, to: number): this | Pages by index interval [from, to] (inclusive, base 0). |
cursor(cursor: string): this | Keyset pagination: pass the opaque next_cursor of the previous page (preferable to offset on large tables: stable, without dup/skip). |
count(mode?: CountMode): this | Requests the total number of matching rows (default 'exact', or 'estimated'), returned in count. |
single<ResultOne = Result extends (infer U)[] ? U : Result>(): AuraPostgrestBuilder<ClientOptions, ResultOne, ThrowOnError> | Waits for exactly one row and returns the object itself; 0 or several rows give the error PGRST116. |
maybeSingle<ResultOne = Result extends (infer U)[] ? U : Result>(): AuraPostgrestBuilder<ClientOptions, ResultOne | null, ThrowOnError> | Like single(), but 0 rows are not an error: data is then null. |
#
Class
AuraPostgrestBuilder
Base class: shared state, constructor, HTTP execution (then/_execute), throwOnError and buildQueryString.
| Method | Description |
|---|---|
throwOnError(): this | Throws an exception (instead of returning { error }) when the request fails. |
buildQueryString(): string | Constructs the query string PostgREST (select, filters, sort, pagination) without running the query; useful for debugging. |
then<TResult1 = AuraResponse<Result>, TResult2 = never>(onfulfilled?: ((value: AuraResponse<Result>) => TResult1 | PromiseLike<TResult1>) | null, onrejected?: ((reason: unknown) => TResult2 | PromiseLike<TResult2>) | null): Promise<TResult1 | TResult2> | Executes the query: the builder is “thenable”, a simple await is enough. |
Generated page
This page is generated from the type declarations and comments of the SDK, so it cannot drift from the published code. For worked examples, read the guides.
Last updated · Oct 12, 2026