Skip to content

add dbx#9

Merged
KARTIKrocks merged 1 commit intomainfrom
feature-dbx
Feb 27, 2026
Merged

add dbx#9
KARTIKrocks merged 1 commit intomainfrom
feature-dbx

Conversation

@KARTIKrocks
Copy link
Owner

Added

  • dbx — New dbx package: lightweight, generic row scanner for database/sql — eliminates scan boilerplate while keeping full SQL control
  • dbxSetDefault(db) sets the package-level connection once at startup; all functions use it automatically
  • dbxWithTx(ctx, tx) returns a context that overrides the default with a transaction — all dbx calls in that context use the tx
  • dbxQueryAll[T](ctx, query, args...) scans all rows into []T; returns empty slice for no rows
  • dbxQueryOne[T](ctx, query, args...) scans the first row into T; returns errors.CodeNotFound for no rows
  • dbxExec(ctx, query, args...) executes non-returning queries with errors.CodeDatabaseError wrapping
  • dbx — Q-suffixed variants (QueryAllQ, QueryOneQ, ExecQ) accept sqlbuilder.Query directly
  • dbx — Struct mapping via db:"column_name" tags; db:"-" to skip; untagged fields ignored
  • dbx — Pointer fields (*string, *int, etc.) handle SQL NULLs naturally
  • dbx — Column matching is order-independent; unmatched result columns silently discarded
  • dbx — Embedded struct support (including exported pointer embeds like *Base)
  • dbx — Reflection-based type mapping cached per-type via sync.Map (built once per process lifetime)

@KARTIKrocks KARTIKrocks self-assigned this Feb 27, 2026
@KARTIKrocks KARTIKrocks merged commit 1ae5aa4 into main Feb 27, 2026
3 checks passed
@KARTIKrocks KARTIKrocks deleted the feature-dbx branch March 5, 2026 05:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant