Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrRecordNotFound = errors.New("record not found")
Functions ¶
This section is empty.
Types ¶
type Factory ¶ added in v0.0.2
type Factory interface {
Factory() SerializedItem
}
type IDSetter ¶
type IDSetter interface {
SetID(string)
}
IDSetter interface can be used by the DB to provide new IDs for objects. If Item supports this, when we Create the new item we can set a unique ID based on different DB implementations
type Item ¶
Item is a generic object which can be used to interact with the store. Users can create their own 'Item' for using the store
type ItemFilter ¶ added in v0.0.2
type ItemFilter interface {
Compare(SerializedItem) bool
}
type ListOpt ¶
type ListOpt struct { Page int64 Limit int64 Sort Sort Version int64 Filter ItemFilter }
ListOpt provides different options for querying the DB Pagination can be used if supported by underlying DB
type Serializable ¶
Serializable interface for the Items to store/retrieve data to/from DB as bytes
type SerializedItem ¶ added in v0.0.2
type SerializedItem interface { Item Serializable }
type Sort ¶
type Sort int
Sort is an enum for using different sorting methods on the query
const ( // SortNatural use natural order SortNatural Sort = iota // SortCreatedDesc created newest to oldest SortCreatedDesc // SortCreatedAsc created oldest to newset SortCreatedAsc // SortUpdatedDesc updated newest to oldest SortUpdatedDesc // SortUpdatedAsc updated oldest to newset SortUpdatedAsc )
type Store ¶
type Store interface { Create(Item) error Read(Item) error Update(Item) error Delete(Item) error List(Factory, ListOpt) (Items, error) io.Closer }
Store is a generic KV Store interface which provides an easier interface to access underlying database. It is mainly used to abstract the database used underneath so we can have a uniform API to use for clients
type TimeTracker ¶
type TimeTracker interface { SetCreated(t int64) GetCreated() int64 SetUpdated(t int64) GetUpdated() int64 }
TimeTracker interface implements basic time tracking functionality for the objects. If Item supports this interface, additional indexes can be maintained to support queries based on this