Documentation
¶
Index ¶
Constants ¶
View Source
const ( COLUMN_CONTENT = "content" COLUMN_CREATED_AT = "created_at" COLUMN_ENTITY_ID = "entity_id" COLUMN_ENTITY_TYPE = "entity_type" COLUMN_ID = "id" COLUMN_SOFT_DELETED_AT = "soft_deleted_at" )
Column names for the version table
View Source
const MAX_DATETIME = "9999-12-31 23:59:59"
MAX_DATETIME is a far-future datetime used as the default soft-delete sentinel.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NewStoreOptions ¶
type NewStoreOptions struct {
TableName string
DB *sql.DB
AutomigrateEnabled bool
DebugEnabled bool
Logger *slog.Logger
}
NewStoreOptions define the options for creating a new version store
type StoreInterface ¶
type StoreInterface interface {
// GetTableName returns the table name
GetTableName() string
// SetTableName sets the table name
SetTableName(tableName string)
// MigrateDown drops the table
MigrateDown(ctx context.Context, tx ...*sql.Tx) error
// MigrateUp creates the table
MigrateUp(ctx context.Context, tx ...*sql.Tx) error
EnableDebug(debug bool)
VersionCreate(ctx context.Context, version VersionInterface) error
VersionFindByID(ctx context.Context, versionID string) (VersionInterface, error)
VersionList(ctx context.Context, query VersionQueryInterface) ([]VersionInterface, error)
VersionUpdate(ctx context.Context, version VersionInterface) error
VersionDelete(ctx context.Context, version VersionInterface) error
VersionDeleteByID(ctx context.Context, versionID string) error
VersionSoftDelete(ctx context.Context, version VersionInterface) error
VersionSoftDeleteByID(ctx context.Context, versionID string) error
}
func NewStore ¶
func NewStore(opts NewStoreOptions) (StoreInterface, error)
NewStore creates a new version store
type VersionInterface ¶
type VersionInterface interface {
IsSoftDeleted() bool
ID() string
SetID(id string) VersionInterface
EntityType() string
SetEntityType(entityType string) VersionInterface
EntityID() string
SetEntityID(entityID string) VersionInterface
Content() string
SetContent(content string) VersionInterface
GetCreatedAt() string
GetCreatedAtCarbon() *carbon.Carbon
SetCreatedAt(createdAt string) VersionInterface
GetSoftDeletedAt() string
GetSoftDeletedAtCarbon() *carbon.Carbon
SetSoftDeletedAt(softDeletedAt string) VersionInterface
}
func NewVersion ¶
func NewVersion() VersionInterface
NewVersion creates a new version with a generated ID and current timestamp
func NewVersionFromExistingData ¶
func NewVersionFromExistingData(data map[string]string) VersionInterface
NewVersionFromExistingData creates a version from existing data
type VersionQueryInterface ¶
type VersionQueryInterface interface {
Validate() error
Columns() []string
SetColumns(columns []string) VersionQueryInterface
HasCountOnly() bool
IsCountOnly() bool
SetCountOnly(countOnly bool) VersionQueryInterface
HasID() bool
ID() string
SetID(id string) VersionQueryInterface
HasEntityID() bool
EntityID() string
SetEntityID(entityID string) VersionQueryInterface
HasEntityType() bool
EntityType() string
SetEntityType(entityType string) VersionQueryInterface
HasOffset() bool
Offset() int64
SetOffset(offset int64) VersionQueryInterface
HasLimit() bool
Limit() int
SetLimit(limit int) VersionQueryInterface
HasSortOrder() bool
SortOrder() string
SetSortOrder(sortOrder string) VersionQueryInterface
HasOrderBy() bool
OrderBy() string
SetOrderBy(orderBy string) VersionQueryInterface
HasSoftDeletedIncluded() bool
SoftDeletedIncluded() bool
SetSoftDeletedIncluded(includeSoftDeleted bool) VersionQueryInterface
}
func NewVersionQuery ¶
func NewVersionQuery() VersionQueryInterface
NewVersionQuery creates a new version query
Click to show internal directories.
Click to hide internal directories.