Documentation
¶
Overview ¶
Package entdb extends the ent db library and satisfies matt's needs for consistency
Index ¶
- func RegisterDatabaseFlags(v *viper.Viper, flags *pflag.FlagSet) error
- type EntClientConfig
- type MultiWriteDriver
- func (d *MultiWriteDriver) BeginTx(ctx context.Context, opts *sql.TxOptions) (dialect.Tx, error)
- func (d *MultiWriteDriver) Close() error
- func (d *MultiWriteDriver) Dialect() string
- func (d *MultiWriteDriver) Exec(ctx context.Context, query string, args, v any) error
- func (d *MultiWriteDriver) Query(ctx context.Context, query string, args, v any) error
- func (d *MultiWriteDriver) Tx(ctx context.Context) (dialect.Tx, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type EntClientConfig ¶
type EntClientConfig struct {
// contains filtered or unexported fields
}
EntClientConfig configures the entsql drivers
func NewDBConfig ¶
func NewDBConfig(c config.DB, l *zap.SugaredLogger) *EntClientConfig
NewDBConfig returns a new database configuration
func (*EntClientConfig) NewMultiDriverDBClient ¶
func (c *EntClientConfig) NewMultiDriverDBClient(ctx context.Context, opts []ent.Option) (*ent.Client, error)
NewMultiDriverDBClient returns a ent client with a primary and secondary, if configured, write database
type MultiWriteDriver ¶
type MultiWriteDriver struct {
// Wp (write-primary), Ws (write-secondary) Drivers
Wp, Ws dialect.Driver
}
MultiWriteDriver allows you to write to a primary and secondary database
func (*MultiWriteDriver) BeginTx ¶
BeginTx adds an log-id for the transaction and calls the underlying driver BeginTx command if it is supported.
func (*MultiWriteDriver) Close ¶
func (d *MultiWriteDriver) Close() error
Close the underlying connections
func (*MultiWriteDriver) Dialect ¶
func (d *MultiWriteDriver) Dialect() string
Dialect returns the dialect name of the primary driver
func (*MultiWriteDriver) Exec ¶
Exec logs its params and calls the underlying driver Exec method for both write drivers
Click to show internal directories.
Click to hide internal directories.