Documentation
¶
Index ¶
- Variables
- type AfterGetInterceptor
- type AfterSaveInterceptor
- type BeforeGetInterceptor
- type BeforeSaveInterceptor
- type BinaryDataStore
- type Datatype
- func (dt *Datatype[T]) Delete(ctx context.Context, key string) error
- func (dt *Datatype[T]) Exists(ctx context.Context, id string) (bool, error)
- func (dt *Datatype[T]) GenerateID() string
- func (dt *Datatype[T]) Get(ctx context.Context, ID string) (*T, error)
- func (dt *Datatype[T]) GetAll(ctx context.Context) ([]*T, error)
- func (dt *Datatype[T]) GetID(ctx context.Context, item *T) string
- func (dt *Datatype[T]) GetRaw(ctx context.Context, ID string) (*T, error)
- func (dt *Datatype[T]) Initialize(ctx context.Context) error
- func (dt *Datatype[T]) NativeQuery(ctx context.Context, query interface{}) ([]T, error)
- func (dt *Datatype[T]) Query(ctx context.Context, query *SimpleQuery) ([]*T, error)
- func (dt *Datatype[T]) Save(ctx context.Context, item *T) (*T, error)
- func (dt *Datatype[T]) SaveRaw(ctx context.Context, item *T) (*T, error)
- func (dt *Datatype[T]) SetID(ctx context.Context, item interface{}, id string)
- func (dt *Datatype[T]) Shutdown(ctx context.Context) error
- type DatatypeCollection
- func (dtc *DatatypeCollection) Add(dt *Datatype[any]) error
- func (dtc *DatatypeCollection) FindByName(name string) *Datatype[any]
- func (dtc *DatatypeCollection) FindByPrefix(prefix string) *Datatype[any]
- func (dtc *DatatypeCollection) FindForId(id string) *Datatype[any]
- func (dtc *DatatypeCollection) Initialize(ctx context.Context) error
- func (dtc *DatatypeCollection) Shutdown(ctx context.Context)
- type FilesystemStore
- func (fs *FilesystemStore) Close(ctx context.Context) error
- func (fs *FilesystemStore) Delete(ctx context.Context, key string) error
- func (fs *FilesystemStore) Exists(ctx context.Context, key string) (bool, error)
- func (fs *FilesystemStore) Get(ctx context.Context, key string) ([]byte, error)
- func (fs *FilesystemStore) Init() error
- func (fs *FilesystemStore) Open(ctx context.Context, config interface{}) error
- func (fs *FilesystemStore) Save(ctx context.Context, data []byte, key string) error
- func (fs *FilesystemStore) SaveStream(ctx context.Context, data io.ReadCloser, key string) (int64, error)
- type Filetype
- type IdGenerator
- type InMemoryStore
- func (mem *InMemoryStore) Close(ctx context.Context) error
- func (mem *InMemoryStore) Delete(ctx context.Context, key string) error
- func (mem *InMemoryStore) Exists(ctx context.Context, key string) (bool, error)
- func (mem *InMemoryStore) Get(ctx context.Context, key string) ([]byte, error)
- func (mem *InMemoryStore) Open(ctx context.Context, config interface{}) error
- func (mem *InMemoryStore) Save(ctx context.Context, data []byte, key string) error
- func (mem *InMemoryStore) SaveStream(ctx context.Context, data io.ReadCloser, key string) (int64, error)
- type Indexer
- type JsonDataStore
- type JsonDataStoreAdapter
- type LoadInput
- type LoadOutput
- type NativeQuerable
- type SimpleQuery
- type SimpleQueryCondition
- func (sqc *SimpleQueryCondition) GetDate(key string) (val time.Time)
- func (sqc *SimpleQueryCondition) GetFloat(key string) float64
- func (sqc *SimpleQueryCondition) GetInt(key string) int
- func (sqc *SimpleQueryCondition) GetString(key string) string
- func (sqc *SimpleQueryCondition) GetStringArr(key string) []string
- func (sqc *SimpleQueryCondition) Set(key string, value interface{})
- type SimpleQueryConditionGroup
- func (cg *SimpleQueryConditionGroup) After(field string, value time.Time)
- func (cg *SimpleQueryConditionGroup) And() *SimpleQueryConditionGroup
- func (cg *SimpleQueryConditionGroup) Before(field string, value time.Time)
- func (cg *SimpleQueryConditionGroup) Between(field string, gte string, lte string)
- func (cg *SimpleQueryConditionGroup) Contains(field string, value string)
- func (cg *SimpleQueryConditionGroup) Equals(field string, value string)
- func (cg *SimpleQueryConditionGroup) Exists(field string, value string)
- func (cg *SimpleQueryConditionGroup) GreaterThan(field string, value string)
- func (cg *SimpleQueryConditionGroup) GreaterThanOrEqual(field string, value string)
- func (cg *SimpleQueryConditionGroup) Includes(field string, values []string)
- func (cg *SimpleQueryConditionGroup) LessThan(field string, value string)
- func (cg *SimpleQueryConditionGroup) LessThanOrEqual(field string, value string)
- func (cg *SimpleQueryConditionGroup) Not() *SimpleQueryConditionGroup
- func (cg *SimpleQueryConditionGroup) Or() *SimpleQueryConditionGroup
- type SortBy
Constants ¶
This section is empty.
Variables ¶
View Source
var PrefixSeparator = "-"
View Source
var RootFSDir = ""
Functions ¶
This section is empty.
Types ¶
type AfterGetInterceptor ¶
type AfterSaveInterceptor ¶
type BeforeGetInterceptor ¶
type BeforeSaveInterceptor ¶
type BinaryDataStore ¶
type BinaryDataStore interface {
Open(ctx context.Context, config interface{}) error
Close(ctx context.Context) error
Save(ctx context.Context, data []byte, key string) error
SaveStream(ctx context.Context, data io.ReadCloser, key string) (int64, error)
Get(ctx context.Context, key string) ([]byte, error)
Delete(ctx context.Context, key string) error
Exists(ctx context.Context, key string) (bool, error)
}
type Datatype ¶
type Datatype[T any] struct { Name string Prefix string IDField string GetIDFunc func(dt *Datatype[T], item interface{}) string SetIDFunc func(dt *Datatype[T], item interface{}, id string) string DataStore JsonDataStore[T] Indexer Indexer[T] ItemType interface{} BeforeSave []BeforeSaveInterceptor[T] AfterSave []AfterSaveInterceptor[T] BeforeGet []BeforeGetInterceptor[T] AfterGet []AfterGetInterceptor[T] // contains filtered or unexported fields }
func (*Datatype[T]) GenerateID ¶
func (*Datatype[T]) GetRaw ¶
Retrieves the Raw Data from the data store and then attempts to unmarshall it using reflection
func (*Datatype[T]) NativeQuery ¶
func (*Datatype[T]) Query ¶
func (dt *Datatype[T]) Query(ctx context.Context, query *SimpleQuery) ([]*T, error)
type DatatypeCollection ¶
type DatatypeCollection struct {
// contains filtered or unexported fields
}
var Datatypes *DatatypeCollection
func NewDatatypeCollection ¶
func NewDatatypeCollection() *DatatypeCollection
func (*DatatypeCollection) FindByName ¶
func (dtc *DatatypeCollection) FindByName(name string) *Datatype[any]
func (*DatatypeCollection) FindByPrefix ¶
func (dtc *DatatypeCollection) FindByPrefix(prefix string) *Datatype[any]
func (*DatatypeCollection) FindForId ¶
func (dtc *DatatypeCollection) FindForId(id string) *Datatype[any]
func (*DatatypeCollection) Initialize ¶
func (dtc *DatatypeCollection) Initialize(ctx context.Context) error
func (*DatatypeCollection) Shutdown ¶
func (dtc *DatatypeCollection) Shutdown(ctx context.Context)
type FilesystemStore ¶
func NewFilesystemStore ¶
func NewFilesystemStore(ext string, dir ...string) *FilesystemStore
func (*FilesystemStore) Delete ¶
func (fs *FilesystemStore) Delete(ctx context.Context, key string) error
func (*FilesystemStore) Init ¶
func (fs *FilesystemStore) Init() error
func (*FilesystemStore) Open ¶
func (fs *FilesystemStore) Open(ctx context.Context, config interface{}) error
func (*FilesystemStore) SaveStream ¶
func (fs *FilesystemStore) SaveStream(ctx context.Context, data io.ReadCloser, key string) (int64, error)
type IdGenerator ¶
type IdGenerator[T any] struct{}
func (*IdGenerator[T]) BeforeSave ¶
func (idgen *IdGenerator[T]) BeforeSave(ctx context.Context, dt *Datatype[T], item *T) (*T, error)
type InMemoryStore ¶
type InMemoryStore struct {
// contains filtered or unexported fields
}
func NewInMemoryStore ¶
func NewInMemoryStore() *InMemoryStore
func (*InMemoryStore) Delete ¶
func (mem *InMemoryStore) Delete(ctx context.Context, key string) error
func (*InMemoryStore) Open ¶
func (mem *InMemoryStore) Open(ctx context.Context, config interface{}) error
func (*InMemoryStore) SaveStream ¶
func (mem *InMemoryStore) SaveStream(ctx context.Context, data io.ReadCloser, key string) (int64, error)
type JsonDataStore ¶
type JsonDataStore[T any] interface { // Open will open the datastore for usage. This should // only be done once per datastore Open(ctx context.Context, config interface{}) error // Close should be called to cleannly close the datastore Close(ctx context.Context) error // Save stores an item in the datastore. There is no difference // between an insert and an update. Save(ctx context.Context, item *T, key string) error // Get retrieves an item by it's unique id Get(ctx context.Context, key string) (*T, error) // Gets all the items in the store. GetAll(ctx context.Context) ([]*T, error) // Deletes an item Delete(ctx context.Context, key string) error // Checks to see if a key exists Exists(ctx context.Context, key string) (bool, error) // Sends a simple Query Query(ctx context.Context, query *SimpleQuery) ([]*T, error) }
JsonDataStore stores data structures as JSON. The type argument can be any struct that the json package can marshal. The type argument must NOT be a pointer type. The config information is based on the driver being used. This will typically contain connection information and the necessary information for generating the table or index.
type JsonDataStoreAdapter ¶
type JsonDataStoreAdapter[T any] struct { DS BinaryDataStore Model T }
func ToJsonDataStore ¶
func ToJsonDataStore[T any](ds BinaryDataStore) *JsonDataStoreAdapter[T]
type LoadOutput ¶
type NativeQuerable ¶
type SimpleQuery ¶
type SimpleQuery struct {
Size int
Offset int
Colums []string
Conditions *SimpleQueryConditionGroup
SortBy []*SortBy
}
SimpleQuery is a simple way to describe conditions and a query
func NewQuery ¶
func NewQuery() *SimpleQuery
type SimpleQueryCondition ¶
func (*SimpleQueryCondition) GetDate ¶
func (sqc *SimpleQueryCondition) GetDate(key string) (val time.Time)
func (*SimpleQueryCondition) GetFloat ¶
func (sqc *SimpleQueryCondition) GetFloat(key string) float64
func (*SimpleQueryCondition) GetInt ¶
func (sqc *SimpleQueryCondition) GetInt(key string) int
func (*SimpleQueryCondition) GetString ¶
func (sqc *SimpleQueryCondition) GetString(key string) string
func (*SimpleQueryCondition) GetStringArr ¶
func (sqc *SimpleQueryCondition) GetStringArr(key string) []string
func (*SimpleQueryCondition) Set ¶
func (sqc *SimpleQueryCondition) Set(key string, value interface{})
type SimpleQueryConditionGroup ¶
type SimpleQueryConditionGroup struct {
Operator string //and, or, no
Conditions []*SimpleQueryCondition
Groups []*SimpleQueryConditionGroup
}
func (*SimpleQueryConditionGroup) After ¶
func (cg *SimpleQueryConditionGroup) After(field string, value time.Time)
func (*SimpleQueryConditionGroup) And ¶
func (cg *SimpleQueryConditionGroup) And() *SimpleQueryConditionGroup
func (*SimpleQueryConditionGroup) Before ¶
func (cg *SimpleQueryConditionGroup) Before(field string, value time.Time)
func (*SimpleQueryConditionGroup) Between ¶
func (cg *SimpleQueryConditionGroup) Between(field string, gte string, lte string)
func (*SimpleQueryConditionGroup) Contains ¶
func (cg *SimpleQueryConditionGroup) Contains(field string, value string)
func (*SimpleQueryConditionGroup) Equals ¶
func (cg *SimpleQueryConditionGroup) Equals(field string, value string)
func (*SimpleQueryConditionGroup) Exists ¶
func (cg *SimpleQueryConditionGroup) Exists(field string, value string)
func (*SimpleQueryConditionGroup) GreaterThan ¶
func (cg *SimpleQueryConditionGroup) GreaterThan(field string, value string)
func (*SimpleQueryConditionGroup) GreaterThanOrEqual ¶
func (cg *SimpleQueryConditionGroup) GreaterThanOrEqual(field string, value string)
func (*SimpleQueryConditionGroup) Includes ¶
func (cg *SimpleQueryConditionGroup) Includes(field string, values []string)
func (*SimpleQueryConditionGroup) LessThan ¶
func (cg *SimpleQueryConditionGroup) LessThan(field string, value string)
func (*SimpleQueryConditionGroup) LessThanOrEqual ¶
func (cg *SimpleQueryConditionGroup) LessThanOrEqual(field string, value string)
func (*SimpleQueryConditionGroup) Not ¶
func (cg *SimpleQueryConditionGroup) Not() *SimpleQueryConditionGroup
func (*SimpleQueryConditionGroup) Or ¶
func (cg *SimpleQueryConditionGroup) Or() *SimpleQueryConditionGroup
Click to show internal directories.
Click to hide internal directories.