resource
resource<
N>(name):ResourceBuilder<{ },never,N>
Defined in: packages/schema/src/resource.ts:497
A resource: one table of an existing database, its columns as fields, its key and the rules around it. name is its
address (/api/v1/<name>) and how other config refers to it. See
Data config.
Type Parameters
Section titled “Type Parameters”N extends string
Parameters
Section titled “Parameters”N
Returns
Section titled “Returns”ResourceBuilder<{ }, never, N>
Example
Section titled “Example”export const customers = resource('customers') .table('shop.customers') .fields({ id: f.integer().readOnly().filterable().sortable().dbDefault(), name: f.text().min(2).filterable().sortable(), email: f.text().optional().filterable(), }) .primaryKey((r) => r.id) .search((r) => [r.name, r.email])