Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SoftDelete ¶
SoftDelete Marks `auditable` as deleted. It also increases the version, updates last update fields, both time and by.
This routine takes `ctx` argument to retrieve the identity.Principal instance performing the operation. If no principal is found, an `unknown` value will be placed instead.
func Touch ¶
Touch increases the version, updates last update fields, both time and by.
This routine takes `ctx` argument to retrieve the identity.Principal instance performing the operation. If no principal is found, an `unknown` value will be placed instead.
Types ¶
type Auditable ¶
type Auditable struct {
CreateTime time.Time
CreateBy string
LastUpdateTime time.Time
LastUpdateBy string
Version int64
IsDeleted bool
// contains filtered or unexported fields
}
Auditable is a structure provisioning metadata for persistence operations.
Embed this structure into your entities/aggregates to enhance and control write operations. Call New routine to create an instance with default values.
Implements persistence.Storable interface.
func New ¶
func New(ctx context.Context, opts ...AuditableOption) Auditable
New allocates a new Auditable instance using default values.
This routine takes `ctx` argument to retrieve the identity.Principal. If no principal is found, an `unknown` value will be placed instead. The principal is used to set the `CreateBy` and `LastUpdateBy` fields.
Use AuditableOption routines to customize how the instance is created.
type AuditableOption ¶
type AuditableOption func(auditable *Auditable)
AuditableOption routine used to set non-required options to Auditable-related routines.
func WithCreateTime ¶
func WithCreateTime(t time.Time) AuditableOption
WithCreateTime sets the creation time for Auditable.
func WithLocation ¶
func WithLocation(loc *time.Location) AuditableOption
WithLocation sets the location for Auditable default timestamps.
This value will be ignored if any of the `createTime` or `updateTime` options are set.
func WithUpdateTime ¶
func WithUpdateTime(t time.Time) AuditableOption
WithUpdateTime sets the last update time for Auditable.
func WithVersion ¶
func WithVersion(version int64) AuditableOption
WithVersion sets the initial version for Auditable.