Documentation ¶
Overview ¶
Package fixtures importing data from YAML files in database for REL.
Usage:
repo := fixtures.New() // Register all needed types repo.Register(&MyTableType{}) // Import data from YAML content err := repo.Import(ctx, db, content)
Index ¶
- type BeforeSave
- type Logger
- type Repository
- func (r Repository) DrawDependencies(w io.Writer) error
- func (r *Repository) Import(ctx context.Context, db rel.Repository, source []byte) error
- func (r *Repository) ImportDir(ctx context.Context, db rel.Repository, path string) error
- func (r *Repository) Register(v any)
- func (r *Repository) SetLogger(l Logger)
- func (r *Repository) SetSkipResolve(skip bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BeforeSave ¶ added in v0.2.0
BeforeSave interface can be implemented by a type to allow changing type data before saving data to database.
type Logger ¶
type Logger interface {
Warn(msg string)
}
Logger to be used by the repository to notify about warnings.
type Repository ¶
type Repository struct {
// contains filtered or unexported fields
}
Repsitory of fixtures that can be loaded and imported.
func (Repository) DrawDependencies ¶
func (r Repository) DrawDependencies(w io.Writer) error
DrawDependencies draws a graph of all tables and their relations in DOT format.
func (*Repository) Import ¶ added in v0.2.0
func (r *Repository) Import(ctx context.Context, db rel.Repository, source []byte) error
Import data from YAML file content.
func (*Repository) ImportDir ¶ added in v0.2.0
func (r *Repository) ImportDir(ctx context.Context, db rel.Repository, path string) error
ImportDir imports data from YAML files in a directory.
func (*Repository) Register ¶
func (r *Repository) Register(v any)
Register a type that can be loaded as fixture.
func (*Repository) SetLogger ¶
func (r *Repository) SetLogger(l Logger)
SetLogger sets the logger to be used by the repository to notify about warnings.
func (*Repository) SetSkipResolve ¶ added in v0.3.0
func (r *Repository) SetSkipResolve(skip bool)
SetSkipResolve sets whether the repository should skip resolving relations and use registration order.