diff --git a/db.go b/db.go index 4d88527..8d23fdc 100644 --- a/db.go +++ b/db.go @@ -204,10 +204,17 @@ func (db *DB) clone(tx pgx.Tx) *DB { return clone } +// SearchPath returns the search path of the database. func (db *DB) SearchPath() string { return db.searchPath } +// Schema returns the Schema instance of the database. +// It should NOT be modified by the caller. +func (db *DB) Schema() *Schema { + return db.schema +} + // ErrIntentionalRollback is an error that can be returned by a transaction function to rollback the transaction. var ErrIntentionalRollback = errors.New("skip error: intentional rollback") diff --git a/repository.go b/repository.go index 6e2ed8b..91aec03 100644 --- a/repository.go +++ b/repository.go @@ -40,6 +40,12 @@ func (repo *Repository[T]) DB() *DB { return repo.db // return the db field } +// Table returns the Table definition instance associated with the Repository instance. +// It should NOT be modified by the caller. +func (repo *Repository[T]) Table() *desc.Table { + return repo.td +} + // QueryRow executes a query that returns at most one row and returns it as a Row instance. func (repo *Repository[T]) QueryRow(ctx context.Context, query string, args ...any) Row { return repo.db.QueryRow(ctx, query, args...)