Documentation
¶
Index ¶
- type DB
- func (db *DB) AutoMigrate(ctx context.Context, appVersion string) error
- func (db *DB) Close() error
- func (db *DB) Connect(_ context.Context, dsn string) (*DB, error)
- func (db *DB) Count(ctx context.Context, options ...QueryOption) (uint64, error)
- func (db *DB) CountAll(ctx context.Context) (uint64, error)
- func (db *DB) Fetch(ctx context.Context, options ...QueryOption) ([]*models.Benchmark, error)
- func (db *DB) FetchByGroupIDs(ctx context.Context, ids []string, options ...QueryOption) ([]*ent.Benchmark, error)
- func (db *DB) FetchByIDs(ctx context.Context, ids []string, options ...QueryOption) ([]*ent.Benchmark, error)
- func (db *DB) FetchGroupIDs(ctx context.Context, options ...QueryOption) ([]string, error)
- func (db *DB) RemoveByGroupIDs(ctx context.Context, ids []string) error
- func (db *DB) RemoveByIDs(ctx context.Context, ids []string) error
- func (db *DB) Save(ctx context.Context, bmark *models.Benchmark) (*models.Benchmark, error)
- func (db *DB) SaveMany(ctx context.Context, bmarks []*models.Benchmark) ([]*models.Benchmark, error)
- func (db *DB) ShouldMigrate(ctx context.Context, appVersion string) (bool, error)
- type FilterFunc
- type QueryOption
- type QueryOptions
- type Store
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB is a struct that represents a database connection.
func (*DB) AutoMigrate ¶
AutoMigrate runs the database migration.
func (*DB) Connect ¶
Connect establishes a connection to the database. It uses the sync.Once.Do function to ensure that the connection is only established once.
func (*DB) FetchByGroupIDs ¶
func (db *DB) FetchByGroupIDs(ctx context.Context, ids []string, options ...QueryOption) ([]*ent.Benchmark, error)
FetchByGroupIDs fetches benchmarks by their group IDs.
func (*DB) FetchByIDs ¶
func (db *DB) FetchByIDs(ctx context.Context, ids []string, options ...QueryOption) ([]*ent.Benchmark, error)
FetchByIDs fetches benchmarks by their IDs.
func (*DB) FetchGroupIDs ¶
FetchGroupIDs fetches group IDs from the database.
func (*DB) RemoveByGroupIDs ¶
RemoveByGroupIDs removes benchmarks by their group IDs.
func (*DB) RemoveByIDs ¶
RemoveByIDs removes benchmarks by their IDs.
type FilterFunc ¶
type FilterFunc func(query *ent.BenchmarkQuery) *ent.BenchmarkQuery
FilterFunc is a type that defines a function that modifies a BenchmarkQuery.
type QueryOption ¶
type QueryOption func(*QueryOptions)
QueryOption is a type that defines a function that modifies a QueryOptions.
func WithFilter ¶
func WithFilter(filterFunc FilterFunc) QueryOption
WithFilter is a function that returns a QueryOption that adds a FilterFunc to the Filters field of a QueryOptions.
func WithLimit ¶
func WithLimit(limit int) QueryOption
WithLimit is a function that returns a QueryOption that sets the Limit field of a QueryOptions.
func WithOffset ¶
func WithOffset(offset int) QueryOption
WithOffset is a function that returns a QueryOption that sets the Offset field of a QueryOptions.
func WithOrderBy ¶
func WithOrderBy(orderFunc func(query *ent.BenchmarkQuery) *ent.BenchmarkQuery) QueryOption
WithOrderBy is a function that returns a QueryOption that sets the OrderBy field of a QueryOptions.
type QueryOptions ¶
type QueryOptions struct { OrderBy func(query *ent.BenchmarkQuery) *ent.BenchmarkQuery Filters []FilterFunc Limit int Offset int }
QueryOptions is a struct that holds options for a query.
type Store ¶
type Store interface { Save(ctx context.Context, res *models.Benchmark) (*models.Benchmark, error) SaveMany(ctx context.Context, res []*models.Benchmark) ([]*models.Benchmark, error) Fetch(ctx context.Context, options ...QueryOption) ([]*models.Benchmark, error) FetchByIDs(ctx context.Context, ids []string, options ...QueryOption) ([]*models.Benchmark, error) FetchByGroupIDs(ctx context.Context, ids []string, options ...QueryOption) ([]*models.Benchmark, error) FetchGroupIDs(ctx context.Context, options ...QueryOption) ([]string, error) Count(ctx context.Context, options ...QueryOption) (uint64, error) CountAll(ctx context.Context) (uint64, error) RemoveByIDs(ctx context.Context, ids []string) error RemoveByGroupIDs(ctx context.Context, ids []string) error }
Store is an interface that defines the methods that a dbench store should implement.