Documentation
¶
Index ¶
- Constants
- type Meta
- type NewStoreOptions
- type Store
- func (st *Store) EnableDebug(debug bool)
- func (st *Store) FindByKey(objectType string, objectID string, key string) (*Meta, error)
- func (st *Store) Get(objectType string, objectID string, key string, valueDefault string) (string, error)
- func (st *Store) GetDB() *sql.DB
- func (st *Store) GetJSON(objectType string, objectID string, key string, valueDefault interface{}) (interface{}, error)
- func (st *Store) GetMetaTableName() string
- func (st *Store) IsAutomigrateEnabled() bool
- func (st *Store) MigrateDown(ctx context.Context, tx ...*sql.Tx) error
- func (st *Store) MigrateUp(ctx context.Context, tx ...*sql.Tx) error
- func (st *Store) Remove(objectType string, objectID string, key string) error
- func (st *Store) Set(objectType string, objectID string, key string, value string) error
- func (st *Store) SetJSON(objectType string, objectID string, key string, value interface{}) error
- type StoreInterface
Constants ¶
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_DELETED_AT = "deleted_at"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_META_KEY = "meta_key"
View Source
const COLUMN_META_VALUE = "meta_value"
View Source
const COLUMN_OBJECT_ID = "object_id"
View Source
const COLUMN_OBJECT_TYPE = "object_type"
View Source
const COLUMN_UPDATED_AT = "updated_at"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Meta ¶
type Meta struct {
ID string `db:"id"`
ObjectType string `db:"object_type"`
ObjectID string `db:"object_id"`
Key string `db:"meta_key"`
Value string `db:"meta_value"`
CreatedAt time.Time `db:"created_at"`
UpdatedAt time.Time `db:"updated_at"`
DeletedAt *time.Time `db:"deleted_at"`
}
Meta type
type NewStoreOptions ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store defines a meta store
func (*Store) EnableDebug ¶
EnableDebug enables or disables debug mode
func (*Store) Get ¶
func (st *Store) Get(objectType string, objectID string, key string, valueDefault string) (string, error)
Get gets a key from cache
func (*Store) GetJSON ¶
func (st *Store) GetJSON(objectType string, objectID string, key string, valueDefault interface{}) (interface{}, error)
GetJSON gets a JSON key from cache
func (*Store) GetMetaTableName ¶
GetMetaTableName returns the meta table name
func (*Store) IsAutomigrateEnabled ¶
IsAutomigrateEnabled returns whether automigrate is enabled
func (*Store) MigrateDown ¶ added in v1.5.0
MigrateDown drops the meta table
type StoreInterface ¶
type StoreInterface interface {
// MigrateDown drops the meta table
MigrateDown(ctx context.Context, tx ...*sql.Tx) error
// MigrateUp creates the meta table
MigrateUp(ctx context.Context, tx ...*sql.Tx) error
// EnableDebug enables or disables debug logging
EnableDebug(debug bool)
// FindByKey finds a meta entry by object type, object ID, and key
FindByKey(objectType string, objectID string, key string) (*Meta, error)
// Get retrieves a value by object type, object ID, and key
Get(objectType string, objectID string, key string, valueDefault string) (string, error)
// GetJSON retrieves and unmarshals a JSON value by object type, object ID, and key
GetJSON(objectType string, objectID string, key string, valueDefault interface{}) (interface{}, error)
// Remove deletes a meta entry by object type, object ID, and key
Remove(objectType string, objectID string, key string) error
// Set stores a string value for a given object type, object ID, and key
Set(objectType string, objectID string, key string, value string) error
// SetJSON marshals and stores a JSON value for a given object type, object ID, and key
SetJSON(objectType string, objectID string, key string, value interface{}) error
// GetMetaTableName returns the meta table name
GetMetaTableName() string
// GetDB returns the database connection
GetDB() *sql.DB
// IsAutomigrateEnabled returns whether automigrate is enabled
IsAutomigrateEnabled() bool
}
StoreInterface defines the interface for meta store operations
func NewStore ¶
func NewStore(opts NewStoreOptions) (StoreInterface, error)
NewStore creates a new meta store
Click to show internal directories.
Click to hide internal directories.