Documentation
¶
Index ¶
- func AllAs[T Storable](items []Storable) ([]T, error)
- func As[T Storable](item Storable) T
- func GetAllAs[T Storable](store Store, typeName string) ([]T, error)
- func GetAs[T Storable](store Store, id *Id) (T, error)
- func GetIndexableBoolValue(item Storable, typeName, propertyName string) (bool, bool)
- func GetIndexableDateTimeValue(item Storable, typeName, propertyName string) (time.Time, bool)
- func GetIndexableFloatValue(item Storable, typeName, propertyName string) (float64, bool)
- func GetIndexableIntValue(item Storable, typeName, propertyName string) (int64, bool)
- func GetIndexableStringValue(item Storable, typeName, propertyName string) (string, bool)
- type BoltStore
- func (bs *BoltStore) AllocateBucketIfNeeded(typeName string) error
- func (bs *BoltStore) AllocateId(item Storable) error
- func (bs *BoltStore) Close() error
- func (bs *BoltStore) Delete(id *Id) error
- func (bs *BoltStore) Exists(id *Id) (bool, error)
- func (bs *BoltStore) Get(id *Id) (Storable, error)
- func (bs *BoltStore) GetAll(typeId int64) ([]Storable, error)
- func (bs *BoltStore) GetAllByTypeName(typeName string) ([]Storable, error)
- func (bs *BoltStore) Match(indexName string, value interface{}) ([]Storable, error)
- func (bs *BoltStore) Put(m Storable) error
- func (bs *BoltStore) PutAll(m []Storable) error
- func (bs *BoltStore) WildcardMatch(indexName string, pattern string) ([]Storable, error)
- type Id
- type IndexDataType
- type IndexDefinition
- type IndexType
- type Storable
- type Store
- type StoreTypeManager
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetIndexableBoolValue ¶
GetIndexableBoolValue uses reflection to extract the bool value of a specified property from a Storable item. It's intended for use in indexing.
Parameters:
- item: The Storable item from which to extract the value.
- typeName: The type name of the item, used for logging purposes.
- propertyName: The name of the property (struct field) to extract.
Returns:
- bool: The bool value of the property if found, accessible, and of bool type.
- bool: True if the property was successfully extracted and is suitable for boolean indexing, false otherwise. If false, a warning will be logged.
func GetIndexableDateTimeValue ¶
GetIndexableDateTimeValue uses reflection to extract the time.Time value of a specified property from a Storable item. It's intended for use in indexing.
Parameters:
- item: The Storable item from which to extract the value.
- typeName: The type name of the item, used for logging purposes.
- propertyName: The name of the property (struct field) to extract.
Returns:
- time.Time: The time.Time value of the property if found, accessible, and of time.Time type.
- bool: True if the property was successfully extracted and is suitable for date/time indexing, false otherwise. If false, a warning will be logged.
func GetIndexableFloatValue ¶
GetIndexableFloatValue uses reflection to extract the float64 value of a specified property from a Storable item. It's intended for use in indexing.
Parameters:
- item: The Storable item from which to extract the value.
- typeName: The type name of the item, used for logging purposes.
- propertyName: The name of the property (struct field) to extract.
Returns:
- float64: The float64 value of the property if found, accessible, and of float64 type.
- bool: True if the property was successfully extracted and is suitable for float indexing, false otherwise. If false, a warning will be logged.
func GetIndexableIntValue ¶
GetIndexableIntValue uses reflection to extract the int64 value of a specified property from a Storable item. It's intended for use in indexing.
Parameters:
- item: The Storable item from which to extract the value.
- typeName: The type name of the item, used for logging purposes.
- propertyName: The name of the property (struct field) to extract.
Returns:
- int64: The int64 value of the property if found, accessible, and of int64 type.
- bool: True if the property was successfully extracted and is suitable for integer indexing, false otherwise. If false, a warning will be logged.
func GetIndexableStringValue ¶
GetIndexableStringValue uses reflection to extract the string value of a specified property from a Storable item. It's intended for use in indexing.
Parameters:
- item: The Storable item from which to extract the value.
- typeName: The type name of the item, used for logging purposes.
- propertyName: The name of the property (struct field) to extract. This is passed in because item.GetTypeName() might be too generic if 'item' is an interface type at the call site.
Returns:
- string: The string value of the property if found, accessible, and of string type.
- bool: True if the property was successfully extracted and is suitable for string indexing, false otherwise. If false, a warning will be logged.
Types ¶
type BoltStore ¶
type BoltStore struct {
// contains filtered or unexported fields
}
func (*BoltStore) AllocateBucketIfNeeded ¶
func (*BoltStore) AllocateId ¶
func (*BoltStore) GetAllByTypeName ¶
GetAllByTypeName retrieves all Storable models of a given typeName.
type IndexDataType ¶
type IndexDataType int
const ( StringIndex IndexDataType = iota Int64Index Float64Index BoolIndex DateTimeIndex )
IndexDataType specifies the underlying data type of the indexed property.
func (IndexDataType) String ¶
func (idt IndexDataType) String() string
String returns the string representation of IndexDataType.
type IndexDefinition ¶
type IndexDefinition struct {
PropertyName string `json:"propertyName"`
Type IndexType `json:"type"`
DataType IndexDataType `json:"dataType"`
}
type Store ¶
type Store interface {
Put(m Storable) error
PutAll(m []Storable) error
Exists(id *Id) (bool, error)
Get(id *Id) (Storable, error)
GetAll(typeId int64) ([]Storable, error)
GetAllByTypeName(typeName string) ([]Storable, error)
Delete(id *Id) error
AllocateId(item Storable) error
AllocateBucketIfNeeded(typeName string) error
// Match finds storables where an indexed property exactly matches the given value.
// The type of 'value' should correspond to the IndexDefinition.DataType of the indexed property.
// indexName is in the form of TypeName.PropertyName.
Match(indexName string, value interface{}) ([]Storable, error)
// WildcardMatch finds storables where an indexed string property matches the given wildcard pattern.
// indexName is in the form of TypeName.PropertyName.
// The property must be indexed and of type StringIndex.
WildcardMatch(indexName string, pattern string) ([]Storable, error)
Close() error
}
func NewBoltStore ¶
func NewBoltStore(path string, typeManager StoreTypeManager) (Store, error)
NewBoltStore creates and returns a new BoltStore. It takes the path to the BoltDB file.