跳转到内容
EN

Count matching database rows without retrieving data

Code Mode: praxis.database.count

SDK 辅助方法:没有单独的 HTTP 端点,在 Code Mode 和 SDK 中调用。

Count rows in an existing table using HEAD. Filters use the same PostgREST query parameters as databaseSelect, for example { status: “eq.active” }. Defaults to exact. Unfiltered counts are exact in every mode; with filters, exact counts within budget, planned returns an unknown total, and estimated may return an unknown total when over budget. Returns { count: number | null }; null means Content-Range reports an unknown total, not zero.

签名

praxis.database.count(input: {
/** Database ID from database list/create, not its display name. */
database_id: string;
/** Existing table name or ID from the database table APIs. */
table: string;
/** PostgREST query filters as in databaseSelect; omitted means all rows. */
filters?: Record<string, string>;
/** exact (default) counts within budget; filtered planned returns null; estimated may return null over budget. Unfiltered counts are exact in every mode. */
count?: 'exact' | 'planned' | 'estimated';
}): Promise<{
/** Matching total, or null when the server reports an unknown total. */
count: number | null;
}>;