import type { SQL, Column } from './types.js'; import type { SQLWrapper } from '../query/sql/sql.js'; /** Returns `column + amount`. Use negative amounts for subtraction. */ export declare function increment(column: Column | SQL, amount: number): SQL; /** Returns `column - amount`. Convenience wrapper — equivalent to `increment(column, -amount)`. */ export declare function decrement(column: Column | SQL, amount: number): SQL; /** Returns `left + right` for two SQL expressions. For column + literal number, use `increment`. */ export declare function add(left: Column | SQL, right: Column | SQL): SQL; /** Returns `left - right` for two SQL expressions. For column - literal number, use `decrement`. */ export declare function subtract(left: Column | SQL, right: Column | SQL): SQL; /** Wraps an expression with COALESCE — returns `defaultValue` when the expression is NULL. */ export declare function coalesce(expression: SQL | Column, defaultValue: T): SQL; /** Returns a SQL expression for PostgreSQL `now()` — the current transaction timestamp. */ export declare function now(): SQL; /** Wraps a select query as a scalar subquery expression, usable in `.values()` and `.set()`. */ export declare function scalar(subquery: SQLWrapper): SQL; /** A PostgreSQL interval/`date_trunc` field unit (`'days'`, `'months'`, …). */ export type IntervalUnit = 'microseconds' | 'milliseconds' | 'seconds' | 'minutes' | 'hours' | 'days' | 'weeks' | 'months' | 'years'; /** PostgreSQL type cast: `expression::pgType`. */ export declare function cast(expression: SQL | Column | SQLWrapper, pgType: string): SQL; /** PostgreSQL interval literal: `interval '5 minutes'`. */ export declare function interval(amount: number, unit: IntervalUnit): SQL; /** PostgreSQL `date_trunc('unit', column)` — truncates a timestamp to the given precision. */ export declare function dateTrunc(unit: 'microseconds' | 'milliseconds' | 'second' | 'minute' | 'hour' | 'day' | 'week' | 'month' | 'quarter' | 'year' | 'decade' | 'century' | 'millennium', column: Column | SQL): SQL; /** PostgreSQL `ROW_NUMBER()` window function. Use with `over()` to apply a window specification. */ export declare function rowNumber(): SQL; /** PostgreSQL `RANK()` window function. Use with `over()` to apply a window specification. */ export declare function rank(): SQL; /** PostgreSQL `DENSE_RANK()` window function. Use with `over()` to apply a window specification. */ export declare function denseRank(): SQL; /** A window-frame specification — the `PARTITION BY` / `ORDER BY` clauses applied by {@link over}. */ export interface WindowSpec { readonly partitionBy?: Column | SQL | ReadonlyArray; readonly orderBy?: SQL | ReadonlyArray; } /** Applies a window specification to a window function or aggregate: `fn OVER (PARTITION BY ... ORDER BY ...)`. */ export declare function over(fn: SQL, spec: WindowSpec): SQL; /** * PostgreSQL quoted identifier. One part renders `"name"`; multiple parts * dot-qualify: `identifier('t', 'n')` → `"t"."n"`. Each part is one * identifier — a dot inside a part is quoted literally, not a qualifier. */ export declare function identifier(first: string, ...rest: string[]): SQL; /** PostgreSQL `WITH RECURSIVE alias AS (seed UNION ALL step) finalQuery`. If `finalQuery` is omitted, defaults to `SELECT * FROM alias`. */ export declare function withRecursive(alias: string, seed: SQL, step: SQL, finalQuery?: SQL): SQL; /** One `WHEN THEN ` branch of a {@link caseWhen} expression. */ export interface CaseBranch { readonly when: SQL | Column; readonly then: T | SQL | Column; } /** PostgreSQL `CASE WHEN .. THEN .. [ELSE ..] END`. Branches evaluate in order; without `elseValue` an unmatched row yields NULL. */ export declare function caseWhen(branches: ReadonlyArray>, elseValue?: T | SQL | Column): SQL; /** PostgreSQL `pg_current_wal_lsn()` — returns the current WAL write position on the primary, as text. */ export declare function walCurrentLsn(): SQL; /** PostgreSQL `pg_last_wal_replay_lsn()` — returns the last replayed WAL position on a replica, as text. Returns NULL on the primary. */ export declare function walReplayLsn(): SQL; /** PostgreSQL `pg_last_wal_replay_lsn() >= lsn::pg_lsn` — true once a replica has replayed up to the given LSN. Yields NULL (not true) on a primary, where there is no replay position. */ export declare function replicaFresh(createdLsn: string | Column | SQL): SQL; //# sourceMappingURL=expressions.d.ts.map