Kysely SQL helpers for Postgres JSON and time operations.
// Source: https://github.com/truefoundry/trueforge | License: MIT | Copyright 2024-2026 TrueFoundry
// Provided via justclaw.it.com; keep this notice with the code.
/**
* Shared Kysely SQL expression helpers for Postgres stores.
*/
import { sql, type Expression, type RawBuilder, type SelectQueryBuilder } from 'kysely';
import type { Database } from './types';
/** Bind a JS value as jsonb (stringified + cast). Required for arrays and for `||` / jsonb_set operands. */
export function json<T>(value: T): RawBuilder<T> {
return sql`${JSON.stringify(value)}::jsonb`;
}
/** Same as {@link json} for loosely typed import payloads. */
export function jsonUnknown<T>(value: unknown): RawBuilder<T> {
return sql`${JSON.stringify(value)}::jsonb`;
}
/**
* `jsonb_set(target, path, new_value)`.
*
... (truncated -- full source via MCP)
See the full source, get the GitHub permalink, and search for more like it.
Get a free API key