feat(knex-schema): define queries before binding a connection - #242
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Add connection-independent query definitions so reads can be defined once in a data module and receive an injected Knex connection or transaction at execution.
Parameterless definitions use the same API:
query(UserSchema)(knex)or.query(knex).Behavior and implementation
.query(knex, ...values)returns an independent ordinary reader. Bind before pagination, permitted writes, native subqueries,ref(),apply()or raw projections. Native escape hatches expose real Knex snapshots, including normal listener semantics.query(knex, Schema),createQuery(knex)and connection-bound ORM DbSet APIs supported. Standalone reads remain detached from ORM identity tracking.Documentation and release
@cleverbrush/knex-schemaand@cleverbrush/orm; existing release grouping and pending changesets are unchanged.Validation
npm run lintnpm run buildnpm run test: 4,759 passing tests across 241 files; no type errorsnpm run typecheck:schema-sitenpm run typecheck:docs-siteCapability-named regression tests cover metadata without a connection, callback capture, inference, invalid arguments, immutable values, compilation reuse/isolation and native SQL escape hatches.
GitHub CI passed on
cb5d6222: lint/build/tests and both site typechecks, PostgreSQL query/scheduler integration and durable-job demos, and S3 storage integration.