Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
*drel.Engine
Posts *posts.PostRepository
Users *users.UserRepository
Modules Modules
}
func (*DB) Tx ¶
Tx returns the tracked repositories bound to the transaction in ctx. It panics if no transaction is present, so wrap the call in WithTx.
func (*DB) WithTx ¶
func (db *DB) WithTx(ctx context.Context, fn func(ctx context.Context) error, opts ...drel.TxOption) error
WithTx runs fn inside a transaction and puts that transaction in the context it passes to fn. Reach the tracked repositories with db.Tx(ctx). A nested call opens a savepoint on the same transaction.
type Modules ¶
type Modules struct {
Posts PostsRepos
Users UsersRepos
}
Modules groups the untracked repositories by feature slice, so a slice reaches only its own models.
type PostsRepos ¶
type PostsRepos struct {
Posts *posts.PostRepository
}
PostsRepos holds the untracked repositories of the "posts" module.
type PostsTxRepos ¶
type PostsTxRepos struct {
Posts *posts.TxPostRepository
}
PostsTxRepos holds the tracked repositories of the "posts" module.
type TxModules ¶
type TxModules struct {
Posts PostsTxRepos
Users UsersTxRepos
}
TxModules groups the tracked repositories by feature slice. Every set is bound to the same transaction.
type TxRepos ¶
type TxRepos struct {
Posts *posts.TxPostRepository
Users *users.TxUserRepository
Modules TxModules
}
TxRepos holds the tracked repositories of one transaction. Load through the fields, stage with Add and Remove, then let WithTx commit.
type UsersRepos ¶
type UsersRepos struct {
Users *users.UserRepository
}
UsersRepos holds the untracked repositories of the "users" module.
type UsersTxRepos ¶
type UsersTxRepos struct {
Users *users.TxUserRepository
}
UsersTxRepos holds the tracked repositories of the "users" module.