Documentation ¶
Index ¶
Constants ¶
View Source
const ( // SortOrderAscending defines the order of ascending for sorting SortOrderAscending = SortOrder(1) // SortOrderDescending defines the order of descending for sorting SortOrderDescending = SortOrder(-1) )
Variables ¶
View Source
var ( // ErrPrimaryEmpty Error that primary key is empty. ErrPrimaryEmpty = NewDBError(fmt.Errorf("entity primary is empty")) // ErrTableNameEmpty Error that table name is empty. ErrTableNameEmpty = NewDBError(fmt.Errorf("entity table name is empty")) // ErrNilEntity Error that entity is nil ErrNilEntity = NewDBError(fmt.Errorf("entity is nil")) // ErrRecordExist Error that entity primary key is exist ErrRecordExist = NewDBError(fmt.Errorf("data record is exist")) // ErrRecordNotExist Error that entity primary key is not exist ErrRecordNotExist = NewDBError(fmt.Errorf("data record is not exist")) // ErrIndexInvalid Error that entity index is invalid ErrIndexInvalid = NewDBError(fmt.Errorf("entity index is invalid")) // ErrEntityInvalid Error that entity is invalid ErrEntityInvalid = NewDBError(fmt.Errorf("entity is invalid")) )
Functions ¶
Types ¶
type DBError ¶ added in v1.2.0
type DBError struct {
// contains filtered or unexported fields
}
DBError datastore error
type DataStore ¶
type DataStore interface { // Add adds entity to database, Name() and TableName() can't return zero value. Add(ctx context.Context, entity Entity) error // BatchAdd will adds batched entities to database, Name() and TableName() can't return zero value. BatchAdd(ctx context.Context, entities []Entity) error // Put will update entity to database, Name() and TableName() can't return zero value. Put(ctx context.Context, entity Entity) error // Delete entity from database, Name() and TableName() can't return zero value. Delete(ctx context.Context, entity Entity) error // Get entity from database, Name() and TableName() can't return zero value. Get(ctx context.Context, entity Entity) error // List entities from database, TableName() can't return zero value. List(ctx context.Context, query Entity, options *ListOptions) ([]Entity, error) // Count entities from database, TableName() can't return zero value. Count(ctx context.Context, entity Entity, options *FilterOptions) (int64, error) // IsExist Name() and TableName() can't return zero value. IsExist(ctx context.Context, entity Entity) (bool, error) }
DataStore datastore interface
type Entity ¶ added in v1.2.0
type Entity interface { SetCreateTime(time time.Time) SetUpdateTime(time time.Time) PrimaryKey() string TableName() string Index() map[string]string }
Entity database data model
type FilterOptions ¶ added in v1.2.0
type FilterOptions struct {
Queries []FuzzyQueryOption
}
FilterOptions filter query returned items
type FuzzyQueryOption ¶ added in v1.2.0
FuzzyQueryOption defines the fuzzy query search filter option
type ListOptions ¶ added in v1.2.0
type ListOptions struct { FilterOptions Page int PageSize int SortBy []SortOption }
ListOptions list api options
type SortOption ¶ added in v1.2.0
SortOption describes the sorting parameters for list
Click to show internal directories.
Click to hide internal directories.