Documentation
¶
Index ¶
Constants ¶
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_MEMO = "memo"
View Source
const COLUMN_METAS = "metas"
View Source
const COLUMN_PAYLOAD = "payload"
View Source
const COLUMN_RECORD_TYPE = "record_type"
View Source
const COLUMN_SOFT_DELETED_AT = "soft_deleted_at"
View Source
const COLUMN_UPDATED_AT = "updated_at"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type NewStoreOptions ¶
type NewStoreOptions struct {
TableName string
DB *sql.DB
DbDriverName string
TimeoutSeconds int64
AutomigrateEnabled bool
DebugEnabled bool
Logger *slog.Logger
}
NewStoreOptions define the options for creating a new session store
type RecordInterface ¶
type RecordInterface interface {
dataobject.DataObjectInterface
IsSoftDeleted() bool
CreatedAt() string
CreatedAtCarbon() *carbon.Carbon
SetCreatedAt(createdAt string)
ID() string
SetID(id string)
Type() string
SetType(t string)
Meta(name string) string
SetMeta(name, value string) error
Metas() (map[string]string, error)
SetMetas(metas map[string]string) error
UpsertMetas(metas map[string]string) error
Memo() string
SetMemo(memo string)
Payload() string
SetPayload(payload string)
PayloadMap() (map[string]any, error)
SetPayloadMap(payloadMap map[string]any) error
PayloadMapKey(key string) (any, error)
SetPayloadMapKey(key string, value any) error
SoftDeletedAt() string
SoftDeletedAtCarbon() *carbon.Carbon
SetSoftDeletedAt(softDeletedAt string)
UpdatedAt() string
UpdatedAtCarbon() *carbon.Carbon
SetUpdatedAt(updatedAt string)
}
RecordInterface represents an record for accessing the API
func NewRecord ¶
func NewRecord(recordType string, opts ...RecordOption) RecordInterface
func NewRecordFromExistingData ¶
func NewRecordFromExistingData(data map[string]string) RecordInterface
type RecordOption ¶
type RecordOption func(RecordInterface) error
RecordOption represents a functional option that mutates a RecordInterface instance during construction or afterwards.
func WithMetas ¶
func WithMetas(metas map[string]string) RecordOption
WithMetas sets the record metas (overwrites existing metas).
func WithPayload ¶
func WithPayload(payload string) RecordOption
WithPayload sets the record payload (raw JSON string).
func WithPayloadMap ¶
func WithPayloadMap(payloadMap map[string]any) RecordOption
WithPayloadMap sets the record payload from a map (will be marshaled to JSON).
type RecordQueryInterface ¶
type RecordQueryInterface interface {
Validate() error
ToSelectDataset(driver string, table string) (selectDataset *goqu.SelectDataset, columns []any, err error)
IsSoftDeletedIncluded() bool
SetSoftDeletedIncluded(softDeletedIncluded bool) RecordQueryInterface
SetColumns(columns []string) RecordQueryInterface
GetColumns() []string
IsCountOnly() bool
SetCountOnly(countOnly bool) RecordQueryInterface
IsIDSet() bool
GetID() string
SetID(id string) RecordQueryInterface
// Multiple IDs support
IsIDListSet() bool
GetIDList() []string
SetIDList(ids []string) RecordQueryInterface
IsTypeSet() bool
GetType() string
SetType(recordType string) RecordQueryInterface
IsLimitSet() bool
GetLimit() int
SetLimit(limit int) RecordQueryInterface
IsOffsetSet() bool
GetOffset() int
SetOffset(offset int) RecordQueryInterface
IsOrderBySet() bool
GetOrderBy() string
SetOrderBy(orderBy string) RecordQueryInterface
// Payload search methods
AddPayloadSearch(needle string) RecordQueryInterface
GetPayloadSearch() []string
AddPayloadSearchNot(needle string) RecordQueryInterface
GetPayloadSearchNot() []string
}
RecordQueryInterface defines the interface for API record query operations
func NewRecordQuery ¶
func NewRecordQuery() RecordQueryInterface
type StoreInterface ¶
type StoreInterface interface {
// AutoMigrate migrates the tables
AutoMigrate() error
// EnableDebug - enables the debug option
EnableDebug(debug bool)
// RecordCount returns the count of records based on a query
RecordCount(query RecordQueryInterface) (int64, error)
// RecordCreate creates a new record
RecordCreate(record RecordInterface) error
// RecordDelete deletes a record
RecordDelete(record RecordInterface) error
// RecordDeleteByID deletes a record by ID
RecordDeleteByID(id string) error
// RecordFindByID finds a record by ID
RecordFindByID(id string) (RecordInterface, error)
// RecordList returns a list of records
RecordList(query RecordQueryInterface) ([]RecordInterface, error)
// RecordSoftDelete soft deletes a record
RecordSoftDelete(record RecordInterface) error
// RecordSoftDeleteByID soft deletes a record by ID
RecordSoftDeleteByID(id string) error
// RecordUpdate updates a record
RecordUpdate(record RecordInterface) error
}
func NewStore ¶
func NewStore(opts NewStoreOptions) (StoreInterface, error)
NewStore creates a new session store
Click to show internal directories.
Click to hide internal directories.