Documentation
¶
Index ¶
- Constants
- func DocstoreTestCRUD(cs *CachedStore, t *testing.T)
- func DriverBulkTest(d Driver, t *testing.T)
- func DriverCRUDTest(d Driver, t *testing.T)
- func RegisterDriver(name string, fn DriverFactory)
- type CachedStore
- func (s *CachedStore) BulkCreate(ctx context.Context, docs interface{}) error
- func (s *CachedStore) BulkGet(ctx context.Context, ids, docs interface{}) error
- func (s *CachedStore) Create(ctx context.Context, doc interface{}) error
- func (s *CachedStore) Delete(ctx context.Context, id interface{}) error
- func (s *CachedStore) Find(ctx context.Context, query *QueryOpt, docs interface{}) error
- func (s *CachedStore) Get(ctx context.Context, id, doc interface{}) error
- func (s *CachedStore) GetCache() cache.Cache
- func (s *CachedStore) Increment(ctx context.Context, id interface{}, fieldName string, value int) error
- func (s *CachedStore) Migrate(ctx context.Context, config interface{}) error
- func (s *CachedStore) Replace(ctx context.Context, doc interface{}) error
- func (s *CachedStore) Update(ctx context.Context, doc interface{}) error
- func (s *CachedStore) UpdateField(ctx context.Context, id interface{}, key string, value interface{}) error
- type Config
- type DocstoreError
- type Driver
- type DriverFactory
- type Field
- type FilterOpt
- type MemoryStore
- func (m *MemoryStore) BulkCreate(ctx context.Context, docs []interface{}) error
- func (m *MemoryStore) BulkGet(ctx context.Context, ids []interface{}, docs interface{}) error
- func (m *MemoryStore) Create(ctx context.Context, doc interface{}) error
- func (m *MemoryStore) Delete(ctx context.Context, id interface{}) error
- func (m *MemoryStore) Find(ctx context.Context, query *QueryOpt, docs interface{}) error
- func (m *MemoryStore) Get(ctx context.Context, id interface{}, doc interface{}) error
- func (m *MemoryStore) GetIncrement(ctx context.Context, id interface{}, key string, value int, doc interface{}) error
- func (m *MemoryStore) Increment(ctx context.Context, id interface{}, key string, value int) error
- func (m *MemoryStore) Migrate(ctx context.Context, config interface{}) error
- func (m *MemoryStore) Update(ctx context.Context, id, doc interface{}, replace bool) error
- func (m *MemoryStore) UpdateField(ctx context.Context, id interface{}, fields []Field) error
- type QueryOpt
Constants ¶
View Source
const NotFound = DocstoreError("[docstore] document not found")
Variables ¶
This section is empty.
Functions ¶
func DocstoreTestCRUD ¶
func DocstoreTestCRUD(cs *CachedStore, t *testing.T)
func DriverBulkTest ¶
func DriverCRUDTest ¶
func RegisterDriver ¶
func RegisterDriver(name string, fn DriverFactory)
Types ¶
type CachedStore ¶
type CachedStore struct { *Config // contains filtered or unexported fields }
func New ¶
func New(config *Config) (*CachedStore, error)
func NewDocstore ¶
func NewDocstore(storage Driver, cache cache.Cache, config *Config) *CachedStore
func (*CachedStore) BulkCreate ¶
func (s *CachedStore) BulkCreate(ctx context.Context, docs interface{}) error
func (*CachedStore) BulkGet ¶
func (s *CachedStore) BulkGet(ctx context.Context, ids, docs interface{}) error
func (*CachedStore) Create ¶
func (s *CachedStore) Create(ctx context.Context, doc interface{}) error
func (*CachedStore) Delete ¶
func (s *CachedStore) Delete(ctx context.Context, id interface{}) error
func (*CachedStore) Find ¶
func (s *CachedStore) Find(ctx context.Context, query *QueryOpt, docs interface{}) error
func (*CachedStore) GetCache ¶
func (s *CachedStore) GetCache() cache.Cache
func (*CachedStore) Migrate ¶
func (s *CachedStore) Migrate(ctx context.Context, config interface{}) error
func (*CachedStore) Replace ¶
func (s *CachedStore) Replace(ctx context.Context, doc interface{}) error
func (*CachedStore) Update ¶
func (s *CachedStore) Update(ctx context.Context, doc interface{}) error
func (*CachedStore) UpdateField ¶
func (s *CachedStore) UpdateField(ctx context.Context, id interface{}, key string, value interface{}) error
type Config ¶
type Config struct { Database string `json:"db,omitempty"` Collection string `json:"collection,omitempty"` CacheURL string `json:"cache_url,omitempty"` CacheExpiration int `json:"cache_expiration,omitempty"` IDField string `json:"id_field,omitempty"` TimestampField string `json:"timestamp_field,omitempty"` Driver string `json:"driver,omitempty"` Connection interface{} `json:"connection,omitempty"` }
type DocstoreError ¶
type DocstoreError string
func (DocstoreError) Error ¶
func (e DocstoreError) Error() string
type Driver ¶
type Driver interface { //GetID(doc interface{}) (interface{}, error) Create(ctx context.Context, doc interface{}) error Update(ctx context.Context, id, doc interface{}, replace bool) error UpdateField(ctx context.Context, id interface{}, fields []Field) error Increment(ctx context.Context, id interface{}, key string, value int) error GetIncrement(ctx context.Context, id interface{}, key string, value int, doc interface{}) error Delete(ctx context.Context, id interface{}) error Get(ctx context.Context, id interface{}, doc interface{}) error Find(ctx context.Context, query *QueryOpt, docs interface{}) error BulkCreate(ctx context.Context, docs []interface{}) error BulkGet(ctx context.Context, ids []interface{}, docs interface{}) error Migrate(ctx context.Context, config interface{}) error }
func MemoryStoreFactory ¶
type DriverFactory ¶
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
func NewMemoryStore ¶
func NewMemoryStore(name, idField string) *MemoryStore
func (*MemoryStore) BulkCreate ¶
func (m *MemoryStore) BulkCreate(ctx context.Context, docs []interface{}) error
func (*MemoryStore) BulkGet ¶
func (m *MemoryStore) BulkGet(ctx context.Context, ids []interface{}, docs interface{}) error
func (*MemoryStore) Create ¶
func (m *MemoryStore) Create(ctx context.Context, doc interface{}) error
func (*MemoryStore) Delete ¶
func (m *MemoryStore) Delete(ctx context.Context, id interface{}) error
func (*MemoryStore) Find ¶
func (m *MemoryStore) Find(ctx context.Context, query *QueryOpt, docs interface{}) error
func (*MemoryStore) Get ¶
func (m *MemoryStore) Get(ctx context.Context, id interface{}, doc interface{}) error
func (*MemoryStore) GetIncrement ¶
func (*MemoryStore) Migrate ¶
func (m *MemoryStore) Migrate(ctx context.Context, config interface{}) error
func (*MemoryStore) Update ¶
func (m *MemoryStore) Update(ctx context.Context, id, doc interface{}, replace bool) error
func (*MemoryStore) UpdateField ¶
func (m *MemoryStore) UpdateField(ctx context.Context, id interface{}, fields []Field) error
Click to show internal directories.
Click to hide internal directories.