Documentation
¶
Index ¶
- func Initialize(ctx context.Context, log *slog.Logger, opts r.ConnectOpts) error
- func Migrate(ctx context.Context, opts r.ConnectOpts, log *slog.Logger, targetVersion *int, ...) error
- func MustRegisterMigration(m Migration)
- func New(log *slog.Logger, opts r.ConnectOpts) (*datastore, error)
- type Datastore
- type Entity
- type EntityQuery
- type Migration
- type Storage
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Initialize ¶
func Migrate ¶
func Migrate(ctx context.Context, opts r.ConnectOpts, log *slog.Logger, targetVersion *int, dry bool) error
Migrate runs database migrations and puts the database into read only mode for demoted runtime users.
func MustRegisterMigration ¶
func MustRegisterMigration(m Migration)
MustRegisterMigration registers a migration and panics when a problem occurs
Types ¶
type Entity ¶
type Entity interface {
// GetID returns the entity's id
GetID() string
// SetID sets the entity's id
SetID(id string)
// GetChanged returns the entity's changed time
GetChanged() time.Time
// SetChanged sets the entity's changed time
SetChanged(changed time.Time)
// GetCreated sets the entity's creation time
GetCreated() time.Time
// SetCreated sets the entity's creation time
SetCreated(created time.Time)
}
Entity is an interface that allows metal entities to be created and stored into the database with the generic creation and update functions.
see https://go.googlesource.com/proposal/+/HEAD/design/43651-type-parameters.md#pointer-method-example for possible solution to prevent slices of pointers.
type Storage ¶
type Storage[E Entity] interface { Create(ctx context.Context, e E) (E, error) Update(ctx context.Context, new, old E) error Upsert(ctx context.Context, e E) error Delete(ctx context.Context, e E) error Get(ctx context.Context, id string) (E, error) Find(ctx context.Context, queries ...EntityQuery) (E, error) List(ctx context.Context, queries ...EntityQuery) ([]E, error) }
Directories
¶
| Path | Synopsis |
|---|---|
|
Package migrations contains migration functions for migrating the RethinkDB.
|
Package migrations contains migration functions for migrating the RethinkDB. |
Click to show internal directories.
Click to hide internal directories.