@reactor/data — dataclient
@reactor/data / DataClient
Class: DataClient<Schema>
Section titled “Class: DataClient<Schema>”Defined in: client.ts:32
Data client for Reactor - PostgREST-style query builder.
Example
Section titled “Example”const client = new DataClient(ctx);
// Select with filtersconst { data, error } = await client .from('posts') .select('id, title, author:users(name)') .eq('published', true) .order('created_at', { ascending: false }) .limit(10);
// Insertconst { data } = await client .from('posts') .insert({ title: 'Hello', body: 'World' }) .select() .single();
// RPCconst { data } = await client.rpc('search', { query: 'rust' });Type Parameters
Section titled “Type Parameters”Schema
Section titled “Schema”Schema extends GenericSchema = GenericSchema
Constructors
Section titled “Constructors”Constructor
Section titled “Constructor”new DataClient<
Schema>(ctx):DataClient<Schema>
Defined in: client.ts:33
Parameters
Section titled “Parameters”RequestContext
Returns
Section titled “Returns”DataClient<Schema>
Methods
Section titled “Methods”from()
Section titled “from()”from<
TableName>(table):PostgrestQueryBuilder<Schema["Tables"][TableName]["Row"]>
Defined in: client.ts:41
Start a query on a table.
Type Parameters
Section titled “Type Parameters”TableName
Section titled “TableName”TableName extends string
Parameters
Section titled “Parameters”TableName
The table name
Returns
Section titled “Returns”PostgrestQueryBuilder<Schema["Tables"][TableName]["Row"]>
A query builder
rpc<
FunctionName,Args,Returns>(functionName,args?):RpcBuilder<Args,Returns>
Defined in: client.ts:54
Call a database function via RPC.
Type Parameters
Section titled “Type Parameters”FunctionName
Section titled “FunctionName”FunctionName extends string
Args extends Record<string, unknown>
Returns
Section titled “Returns”Returns = Schema["Functions"][FunctionName]["Returns"]
Parameters
Section titled “Parameters”functionName
Section titled “functionName”FunctionName
The function name
Args
Function arguments
Returns
Section titled “Returns”RpcBuilder<Args, Returns>
RPC builder
schema()
Section titled “schema()”schema(
_name):DataClient<Schema>
Defined in: client.ts:73
Access a schema (for multi-schema support). Currently returns self as we only support public schema.
Parameters
Section titled “Parameters”string
Returns
Section titled “Returns”DataClient<Schema>