Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Database ¶ added in v0.1.1
type Database[R, W any] interface { // ReadTx starts a read only transaction. ReadTx(context.Context, func(context.Context, R) error) error // ReadWriteTx starts a read write transaction. ReadWriteTx(context.Context, func(context.Context, W) error) error Migrator io.Closer }
Database provides methods for transactional operations.
func NewDatabase ¶ added in v0.1.1
func NewDatabase[R, W any](conn *gorm.DB, r ReadTxFactory[R], rw ReadWriteTxFactory[W]) (Database[R, W], error)
NewDatabase returns a new instance of db.
type Migrator ¶ added in v0.1.1
type Migrator interface { // Migrate is a method that runs the migration. Migrate(context.Context, ...any) error }
Migrator is a method that runs the migration.
type Opt ¶
type Opt func(*seederImpl)
Opt is a function that configures the Seeder.
func WithDatabase ¶
WithDatabase sets the database for the Seeder.
type QueryError ¶ added in v0.1.1
type QueryError struct { // Query is the query that caused the error. Query string // Err is the error that occurred. Err error }
QueryError is an error that occurred while executing a query.
func NewQueryError ¶ added in v0.1.1
func NewQueryError(query string, err error) *QueryError
NewQueryError returns a new QueryError.
func (*QueryError) Error ¶ added in v0.1.1
func (e *QueryError) Error() string
Error implements the error interface.
func (*QueryError) Unwrap ¶ added in v0.1.1
func (e *QueryError) Unwrap() error
Unwrap implements the errors.Wrapper interface.
type ReadTxFactory ¶ added in v0.1.1
ReadTxFactory is a function that creates a new instance of Datastore.
type ReadWriteTxFactory ¶ added in v0.1.1
ReadWriteTxFactory is a function that creates a new instance of Datastore.
type Seed ¶
type Seed struct { // Name is the name of the seed. Name string // Run is the function that seeds the data. Run SeedFunc }
Seed is a struct that contains the data to be seeded.
Click to show internal directories.
Click to hide internal directories.