Skip to content

Commit

Permalink
export Table definition of the repository and Schema of the database
Browse files Browse the repository at this point in the history
  • Loading branch information
kataras committed Aug 21, 2023
1 parent 980bd5a commit fdf6aff
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
7 changes: 7 additions & 0 deletions db.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down
6 changes: 6 additions & 0 deletions repository.go
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
Expand Down

0 comments on commit fdf6aff

Please sign in to comment.