Skip to main content
Access database methods via client.db. Collections must be created in the urBackend Dashboard before you can interact with them. Methods that return documents accept a generic type parameter T (extending DocumentData) so returned documents are fully typed. Methods like delete() return status objects and do not accept T.

Row-Level Security (RLS)

If a collection has RLS enabled, you must provide the user’s accessToken to perform write operations (insert, update, patch, delete). Example pattern:
const { accessToken } = await client.auth.login({ ... });
await client.db.insert('posts', { content: 'Hello' }, accessToken);

getAll

Fetch documents from a collection with optional filtering, sorting, and pagination.
getAll<T extends DocumentData>(collection: string, params?: QueryParams): Promise<T[]>
Query Parameters (params)
ParameterTypeDescription
filterobjectFilter by field suffixes (e.g. { age_gt: 18 }).
sortstringSort order (e.g. "createdAt:desc").
limitnumberMax documents to return (max 100).
pagenumberPage number for pagination.
populatestring | string[]Expand Reference fields into full objects.
Example
const products = await client.db.getAll<Product>('products', {
  filter: { category: 'electronics', price_lt: 500 },
  sort: 'price:asc',
  limit: 20
});

getOne

Fetch a single document by its ID.
getOne<T extends DocumentData>(collection: string, id: string, options?: { populate?: string | string[] }): Promise<T>
Example
const product = await client.db.getOne<Product>('products', 'id_123', { populate: 'vendor' });

insert

Insert a new document. If RLS is enabled, the token parameter is required.
insert<T extends DocumentData>(collection: string, data: Record<string, unknown>, token?: string): Promise<T>

update

Update an existing document by its ID. This performs a full replacement of the document fields.
update<T extends DocumentData>(collection: string, id: string, data: Record<string, unknown>, token?: string): Promise<T>

patch

Partially update a document. Only the fields provided in data will be modified.
patch<T extends DocumentData>(collection: string, id: string, data: Record<string, unknown>, token?: string): Promise<T>
Example
// Only updates the price, leaves other fields unchanged
await client.db.patch('products', 'id_123', { price: 45 });

delete

Delete a document by its ID.
delete(collection: string, id: string, token?: string): Promise<{ deleted: boolean }>

TypeScript Support

Define your interfaces to get full IDE autocomplete:
interface BlogPost {
  _id: string;
  title: string;
  author: string;
}

const posts = await client.db.getAll<BlogPost>('posts');
posts[0].title; // typed as string