Documentation
¶
Index ¶
- func JSON[T any](ptr *T) flsql.DTO
- func MakeMigrator(conn Connection, namespace string, steps migration.Steps[Connection]) migration.Migrator[Connection]
- func Timestamp(ptr *time.Time) flsql.DTO
- type CacheRepository
- func (r CacheRepository[ENT, ID]) BeginTx(ctx context.Context) (context.Context, error)
- func (r CacheRepository[ENT, ID]) CommitTx(ctx context.Context) error
- func (r CacheRepository[ENT, ID]) Entities() cache.EntityRepository[ENT, ID]
- func (r CacheRepository[ENT, ID]) Hits() cache.HitRepository[ID]
- func (r CacheRepository[ENT, ID]) Migrate(ctx context.Context) error
- func (r CacheRepository[ENT, ID]) RollbackTx(ctx context.Context) error
- type Connection
- type Repository
- func (r Repository[ENT, ID]) BeginTx(ctx context.Context) (context.Context, error)
- func (r Repository[ENT, ID]) CommitTx(ctx context.Context) error
- func (r Repository[ENT, ID]) Create(ctx context.Context, ptr *ENT) (rErr error)
- func (r Repository[ENT, ID]) DeleteAll(ctx context.Context) (rErr error)
- func (r Repository[ENT, ID]) DeleteByID(ctx context.Context, id ID) (rErr error)
- func (r Repository[ENT, ID]) FindAll(ctx context.Context) (iterators.Iterator[ENT], error)
- func (r Repository[ENT, ID]) FindByID(ctx context.Context, id ID) (ENT, bool, error)
- func (r Repository[ENT, ID]) FindByIDs(ctx context.Context, ids ...ID) (iterators.Iterator[ENT], error)
- func (r Repository[ENT, ID]) RollbackTx(ctx context.Context) error
- func (r Repository[ENT, ID]) Save(ctx context.Context, ptr *ENT) (rErr error)
- func (r Repository[ENT, ID]) Update(ctx context.Context, ptr *ENT) (rErr error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func MakeMigrator ¶
func MakeMigrator(conn Connection, namespace string, steps migration.Steps[Connection]) migration.Migrator[Connection]
Types ¶
type CacheRepository ¶
type CacheRepository[ENT, ID any] struct { Connection Connection // ID [required] is unique identifier. the table name prefix used to create the cache repository tables. // // Example: // ID: "foo" // -> "foo_cache_entities" // ID string // JSONDTOM [optional] is the mapping between an ENT type and a JSON DTO type, // which is used to encode entities within the entity repository. // This mapping is important because if the entity type changes during refactoring, // the previously cached data can still be correctly decoded using the JSON DTO. // This means you won’t need to delete cached data or worry about data corruption. // It provides a safeguard, ensuring smooth transitions without affecting stored data. JSONDTOM dtokit.Mapper[ENT] // IDA is the ID accessor, that explains how the ID field of the ENT can be accessed. IDA extid.Accessor[ENT, ID] // IDM is the mapping between ID and the string type which is used in the CacheRepository tables to represent the ID value. // If the ID is a string type, then this field can be ignored. IDM dtokit.MapperTo[ID, string] }
CacheRepository is a generic implementation for using mysql as a caching backend with `frameless/pkg/cache.Cache`. CacheRepository implements `cache.Repository[ENT,ID]`
func (CacheRepository[ENT, ID]) CommitTx ¶
func (r CacheRepository[ENT, ID]) CommitTx(ctx context.Context) error
func (CacheRepository[ENT, ID]) Entities ¶
func (r CacheRepository[ENT, ID]) Entities() cache.EntityRepository[ENT, ID]
func (CacheRepository[ENT, ID]) Hits ¶
func (r CacheRepository[ENT, ID]) Hits() cache.HitRepository[ID]
func (CacheRepository[ENT, ID]) Migrate ¶
func (r CacheRepository[ENT, ID]) Migrate(ctx context.Context) error
func (CacheRepository[ENT, ID]) RollbackTx ¶
func (r CacheRepository[ENT, ID]) RollbackTx(ctx context.Context) error
type Connection ¶
func Connect ¶
func Connect(dsn string) (Connection, error)
type Repository ¶
type Repository[ENT, ID any] struct { Connection Connection Mapping flsql.Mapping[ENT, ID] }
Repository implements CRUD operations for a specific entity type in mariadb.
func MakeMigrationStateRepository ¶
func MakeMigrationStateRepository(conn Connection) Repository[migration.State, migration.StateID]
func (Repository[ENT, ID]) CommitTx ¶
func (r Repository[ENT, ID]) CommitTx(ctx context.Context) error
CommitTx implements the comproto.OnePhaseCommitter interface.
func (Repository[ENT, ID]) Create ¶
func (r Repository[ENT, ID]) Create(ctx context.Context, ptr *ENT) (rErr error)
func (Repository[ENT, ID]) DeleteAll ¶
func (r Repository[ENT, ID]) DeleteAll(ctx context.Context) (rErr error)
func (Repository[ENT, ID]) DeleteByID ¶
func (r Repository[ENT, ID]) DeleteByID(ctx context.Context, id ID) (rErr error)
func (Repository[ENT, ID]) FindByID ¶
func (r Repository[ENT, ID]) FindByID(ctx context.Context, id ID) (ENT, bool, error)
func (Repository[ENT, ID]) RollbackTx ¶
func (r Repository[ENT, ID]) RollbackTx(ctx context.Context) error
RollbackTx implements the comproto.OnePhaseCommitter interface.
Click to show internal directories.
Click to hide internal directories.