jsonArrayFrom (helpers/postgres.ts)

kysely · src/helpers/postgres.ts · typescript · MIT
database

PostgreSQL helpers for aggregating subqueries into JSON arrays, objects, and building JSON objects.

// Source: https://github.com/kysely-org/kysely | License: MIT | Copyright 2022 Sami Koskimäki
// Provided via justclaw.it.com; keep this notice with the code.
import type { Expression } from '../expression/expression.js'
import type { RawBuilder } from '../raw-builder/raw-builder.js'
import { sql } from '../raw-builder/sql.js'
import type {
  ShallowDehydrateValue,
  ShallowDehydrateObject,
  Simplify,
} from '../util/type-utils.js'

/**
 * A postgres helper for aggregating a subquery (or other expression) into a JSONB array.
 *
 * ### Examples
 *
 * <!-- siteExample("select", "Nested array", 110) -->
 *
 * While kysely is not an ORM and it doesn't have the concept of relations, we do provide
 * helpers for fetching nested objects and arrays in a single query. In this example we
 * use th

... (truncated -- full source via MCP)

See the full source, get the GitHub permalink, and search for more like it.

Get a free API key