import type { DataType, StatementResultSet } from "./protocol.js"; export type Value = bigint | number | boolean | string | Date | null; /** * How to represent integer values returned from `int` / `uint` columns. * * - `'bigint'` (default): native JS `bigint`, preserves I64 precision but is * NOT directly JSON-serializable (`JSON.stringify` will throw * `TypeError: Do not know how to serialize a BigInt`). * - `'number'`: JS `number`. Fast and JSON-safe, but loses precision for * values outside the safe integer range (`Number.MIN_SAFE_INTEGER` to * `Number.MAX_SAFE_INTEGER`, i.e. `±(2**53 - 1)`). Safe for typical * `count(...)` results and bounded counters; not safe for unbounded I64 * identifiers. Throws if the cell is not a base-10 integer string. * - `'string'`: decimal string. Always safe; callers can `BigInt(s)` on read. */ export type IntegerMode = "bigint" | "number" | "string"; export interface IntoOptions { /** How to represent `int` / `uint` cell values. Defaults to `'bigint'`. */ integerMode?: IntegerMode; } /** Options used by typed result conversion helpers. */ export type ResultOptions = IntoOptions; export declare class FieldSchema { private readonly fieldName; private readonly fieldDataType; constructor(fieldName: string, fieldDataType: DataType); name(): string; dataType(): DataType; } export declare class Schema { private readonly schemaFields; constructor(schemaFields: FieldSchema[]); fields(): readonly FieldSchema[]; } export declare class ResultSet { private readonly resultSchema; private readonly totalRows; private readonly rows; constructor(resultSchema: Schema, totalRows: number, rows: Array>); numRows(): number; schema(): Schema; rawRows(): ReadonlyArray>; /** @deprecated Use `rawRows()`. */ jsonRows(): ReadonlyArray>; toValues(options?: IntoOptions): Value[][]; /** @deprecated Use `toValues()`. */ intoValues(options?: IntoOptions): Value[][]; private parseValues; /** * Returns all rows as plain objects keyed by column name. * * This is the most convenient form for typical application code — use this * instead of `toValues()` when you need to access columns by name. * * @example * // Default: integer cells come back as bigint (preserves I64 precision, * // NOT directly JSON-serializable). * const rows = result.toObjects(); * console.log(rows[0]?.["user_id"]); // bigint * * @example * // Opt in to JSON-safe representation for integer cells. * const rows = result.toObjects({ integerMode: "number" }); * JSON.stringify(rows[0]); // safe */ toObjects(options?: IntoOptions): Record[]; /** @deprecated Use `toObjects()`. */ intoObjects(options?: IntoOptions): Record[]; /** * Returns the first row as a plain object keyed by column name, or `null` * if the result set is empty. * * Useful for queries that return at most one row (lookups, aggregates, etc.). * * @example * const row = result.first(); * if (row !== null) { * console.log(row["count"]); // bigint * } * * @example * // JSON-safe integer cells. * const row = result.first({ integerMode: "number" }); * JSON.stringify(row); // safe */ first(options?: IntoOptions): Record | null; static fromStatementResultSet(resultSet: StatementResultSet): ResultSet; } //# sourceMappingURL=result.d.ts.map