Documentation
¶
Index ¶
- func GetNewID() string
- func GetQueryByCriteria(c *firestore.Client, q *QueryCriteria) (query *firestore.Query, err error)
- func HandleResults(ctx context.Context, docs *firestore.DocumentIterator, h ResultHandler) error
- func IsValidID(val string) bool
- func NewClient(ctx context.Context) (client *firestore.Client, err error)
- func ToID(val string) string
- type Criterion
- type MockedStoreObject
- type Order
- type QueryCriteria
- type ResultHandler
- type Store
- func (d *Store) Close() error
- func (d *Store) DeleteAll(ctx context.Context, collection string, batchSize int) error
- func (d *Store) DeleteByID(ctx context.Context, collection, id string) error
- func (d *Store) GetByID(ctx context.Context, collection, id string, in interface{}) error
- func (d *Store) GetByQuery(ctx context.Context, q *QueryCriteria, h ResultHandler) error
- func (d *Store) Save(ctx context.Context, collection string, id string, obj interface{}) error
- type TestObjectHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetNewID ¶
func GetNewID() string
GetNewID parses Firestore valid IDs (can't start with digits)
func GetQueryByCriteria ¶
GetQueryByCriteria builds Firestore query
func HandleResults ¶
func HandleResults(ctx context.Context, docs *firestore.DocumentIterator, h ResultHandler) error
HandleResults allows for filtered query using QueryHandler
Types ¶
type Criterion ¶
type Criterion struct { // Property is the name of the property in where clause. Assumes index in Firestore Property string Operator string Value interface{} }
Criterion defines single Firestore where criteria
type MockedStoreObject ¶
type MockedStoreObject struct { ID string `json:"id" firestore:"id"` On time.Time `json:"on" firestore:"on"` Name string `json:"name" firestore:"name"` Count int `json:"count" firestore:"count"` Value float64 `json:"value" firestore:"value"` }
MockedStoreObject represents simple object
func NewTestObject ¶
func NewTestObject(name string, count int, value float64) *MockedStoreObject
NewTestObject returns fully loaded Firestore object
type QueryCriteria ¶
QueryCriteria defines the Firestore query query
type ResultHandler ¶
type ResultHandler interface { // MakeNew makes new item instance for loading from result iterator MakeNew() interface{} // Append adds newly loaded item to results Append(item interface{}) }
ResultHandler defines methods required to handle result items
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store represents simple FireStore helper
func NewStoreWithCredentialsFile ¶
NewStoreWithCredentialsFile configures new client instance with credentials file
func (*Store) DeleteByID ¶
DeleteByID deletes stored object for a given ID
func (*Store) GetByQuery ¶
func (d *Store) GetByQuery(ctx context.Context, q *QueryCriteria, h ResultHandler) error
GetByQuery allows for filtered query using QueryHandler
type TestObjectHandler ¶
type TestObjectHandler struct {
Items []*MockedStoreObject
}
TestObjectHandler is a test implementation of the QueryHandler interface
func (*TestObjectHandler) Append ¶
func (t *TestObjectHandler) Append(item interface{})
Append adds newly loaded item to results
func (*TestObjectHandler) MakeNew ¶
func (t *TestObjectHandler) MakeNew() interface{}
MakeNew makes new item instance for loading from result iterator