Summary
Migrate the NormalJS core database abstraction from Knex.js to Kysely for improved type-safety, modern query composition, and better TypeScript support.
Background
- Our current implementation relies on Knex.js for query building and connection management in
src/Connection.js, src/Repository.js, and the model/query logic in src/Model.js, src/Record.js.
- Kysely offers superior type inference and stronger TS support, aligned with our goal for strict type coverage throughout the ORM.
Scope
- Replace all Knex imports/usages with Kysely equivalents in connection, transaction, and query builder subsystems.
- Refactor model definition patterns to leverage Kysely’s typed query features.
- Update
Connection class to use Kysely clients (support for PostgreSQL/SQLite must be retained).
- Ensure the lazy loading mechanisms remain compatible and efficient with Kysely.
- Adjust
repo.sync() logic to reflect differences in schema migration APIs.
- Adapt transaction management (
repo.transaction()) for Kysely idioms.
- Validate relation patterns (one-to-many, many-to-many) work with Kysely’s approach.
- Update tests in integration/demo suites to cover the new query builder and ensure 80%+ coverage remains.
Acceptance Criteria
- All core modules rely on Kysely, with no residual Knex references.
- All tests passing (
npm test) and coverage reports >= 80%.
- Demo projects (blog, crm, stocks) function correctly with Kysely.
- Document new architecture and developer setup in README/code comments.
References:
Summary
Migrate the NormalJS core database abstraction from Knex.js to Kysely for improved type-safety, modern query composition, and better TypeScript support.
Background
src/Connection.js,src/Repository.js, and the model/query logic insrc/Model.js,src/Record.js.Scope
Connectionclass to use Kysely clients (support for PostgreSQL/SQLite must be retained).repo.sync()logic to reflect differences in schema migration APIs.repo.transaction()) for Kysely idioms.Acceptance Criteria
npm test) and coverage reports >= 80%.References:
README.mdto guide migration steps.