Remix
Remix
remix/data-table · FunctionView Source

query

Summary

Begin a Query against a @remix-run/data-table source. The returned builder is in 'all' execution mode and unbound; chain select, where, orderBy, etc. to refine the plan, and await it after binding it to a runtime to materialize results.

Signature

function query<
  tableName extends string,
  row extends Record<string, unknown>,
  primaryKey extends readonly (keyof row & string)[],
>(
  table: QueryTableInput<tableName, row, primaryKey>,
): Query<
  QueryTableInput<tableName, row, primaryKey>,
  QueryColumnTypeMapFromRow<tableName, row>,
  row,
  {},
  UnboundQueryPhase<"all">
>;

Example

let activeUsers = await query(users)
  .where({ status: "active" })
  .orderBy("createdAt", "desc")
  .select(["id", "email"]);

Parameters

table

The table or source to query.

Returns

An unbound Query builder rooted at table.