useTable
useTable<
T>(table,buildQuery?,options?):UseQueryResult<NoInfer<T[]>,Error>
Hook for table queries with a simpler API
Type Parameters
Section titled “Type Parameters”| Type Parameter | Default type |
|---|---|
T |
any |
Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
table |
string |
Table name |
buildQuery? |
(query) => QueryBuilder<T> |
Optional function to build the query (e.g., add filters) |
options? |
UseFluxbaseQueryOptions<T> |
Query options including a stable queryKey NOTE: When using buildQuery with filters, provide a custom queryKey that includes the filter values to ensure proper caching. |
Returns
Section titled “Returns”UseQueryResult<NoInfer<T[]>, Error>
Example
Section titled “Example”// Simple query - queryKey is auto-generated from table nameuseTable('users')
// With filters - provide queryKey including filter valuesuseTable('users', (q) => q.eq('status', 'active'), { queryKey: ['users', 'active'] })