Registry / database / kysely-hydrate

kysely-hydrate

JSON →
library0.10.2jsnpmunverified

A TypeScript library extending Kysely with utilities for hydrating SQL query results into rich, nested JavaScript objects. Current version 0.10.2, early release with frequent breaking changes. Unlike traditional ORMs that restrict SQL expressiveness, this library preserves full Kysely query capabilities while enabling nested joins, computed properties, mapped fields, and hydrated writes. Requires Node >=22.18.0 and Kysely ^0.28. Ships TypeScript definitions.

npm install kysely-hydrate
INSTALL
IMPORT
SIG · KYSELY-HYDRATE
K
kysely-hydrate
databasejavascriptv0.10.2
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

querySet
import { querySet } from 'kysely-hydrate'
import { QuerySet } from 'kysely-hydrate'
Function is lowercased; named export, not default.
attachOneOrThrow
import { querySet } from 'kysely-hydrate' // attachOneOrThrow is a method on QuerySet
import { attachOneOrThrow } from 'kysely-hydrate'
attachOneOrThrow is not a named export; it's a method on a QuerySet instance.
leftJoinMany
import { querySet } from 'kysely-hydrate' // used as querySet(db).leftJoinMany(...)
import { leftJoinMany } from 'kysely-hydrate'
leftJoinMany is a method on QuerySet, not a standalone function.

Demonstrates hydrating a user-post one-to-many join into nested objects using Kysely Hydrate.

import { querySet } from 'kysely-hydrate'; import { Kysely, PostgresDialect } from 'kysely'; import pg from 'pg'; const db = new Kysely<{ user: { id: number; name: string }; post: { id: number; title: string; userId: number } }>({ dialect: new PostgresDialect({ pool: new pg.Pool({ connectionString: process.env.DATABASE_URL ?? '' }) }) }); async function main() { const users = await querySet(db) .selectAs('user', db.selectFrom('user').select(['id', 'name'])) .leftJoinMany('posts', querySet(db).selectAs('posts', db.selectFrom('post').select(['id', 'title', 'userId'])), 'posts.userId', 'user.id' ) .execute(); console.log('Hydrated users:', JSON.stringify(users, null, 2)); } main().catch(console.error);
Debug
Known issues
breakingLibrary is in early release; expect breaking changes in minor and patch versions before 1.0.
fix
Pin to exact version and review changelogs before upgrading.
affects: <1.0
gotchaMethods like attachOneOrThrow and leftJoinMany are only available on QuerySet instances, not directly imported.
fix
Always import 'querySet' and chain methods.
affects: >=0.1
gotcharequires Node >=22.18.0; older Node versions will throw import errors.
fix
Use Node 22.18.0 or later, or use a transpiler like esbuild.
affects: >=0.10
breakingKysely peer dependency is ^0.28; incompatible with Kysely 0.27 or 0.29.
fix
Ensure project uses Kysely 0.28.x.
affects: >=0.10
deprecatedNo deprecated features documented yet; API is unstable.
fix
Keep up with GitHub releases for migration guides.
affects: >=0.1
Errors
Common errors & fixes
TypeError: querySet(...).selectAs is not a function
Incorrect import or library not installed properly; or using old version without selectAs.
fix
Ensure kysely-hydrate is installed (npm i kysely-hydrate) and import 'querySet' correctly. Check version >=0.1.
Module not found: Error: Can't resolve 'kysely-hydrate'
Package not installed or missing from package.json.
fix
Run npm install kysely-hydrate
Error: Cannot find module 'kysely' (or 'kysely' peer dependency not met)
Kysely is a peer dependency and not installed.
fix
Install kysely: npm install kysely@^0.28
Upgrade
Version history
0.10.2latest on npm
Audit
Dependencies
kyselyrequiredPeer dependency: core query builder that kysely-hydrate extends
Agent activity
2 hits · last 30 days
node
2
Resources
kysely-hydrate — npm install kysely-hydrate · libregistry