Documentation
¶
Overview ¶
Package firestore implements dstore.Documents backed by firestore.
Index ¶
- func SetContextLogger(l ContextLogger)
- type ContextLogger
- type Firestore
- func (f *Firestore) Collections(ctx context.Context, parent string) ([]*dstore.Collection, error)
- func (f *Firestore) Create(ctx context.Context, path string, values map[string]interface{}) error
- func (f *Firestore) Delete(ctx context.Context, path string) (bool, error)
- func (f *Firestore) DeleteAll(ctx context.Context, paths []string) error
- func (f *Firestore) DocumentIterator(ctx context.Context, parent string, opt ...dstore.Option) (dstore.Iterator, error)
- func (f *Firestore) Documents(ctx context.Context, parent string, opt ...dstore.Option) ([]*dstore.Document, error)
- func (f *Firestore) EventAdd(ctx context.Context, path string, doc events.Document) (int64, error)
- func (f *Firestore) EventPosition(ctx context.Context, path string) (*events.Position, error)
- func (f *Firestore) EventPositions(ctx context.Context, paths []string) (map[string]*events.Position, error)
- func (f *Firestore) Events(ctx context.Context, path string, opt ...events.Option) (events.Iterator, error)
- func (f *Firestore) EventsAdd(ctx context.Context, path string, docs []events.Document) (int64, error)
- func (f *Firestore) EventsDelete(ctx context.Context, path string) (bool, error)
- func (f *Firestore) Exists(ctx context.Context, path string) (bool, error)
- func (f *Firestore) Get(ctx context.Context, path string) (*dstore.Document, error)
- func (f *Firestore) GetAll(ctx context.Context, paths []string) ([]*dstore.Document, error)
- func (f *Firestore) Increment(ctx context.Context, path string, name string, n int64) (int64, int64, error)
- func (f *Firestore) Load(ctx context.Context, path string, v interface{}) (bool, error)
- func (f *Firestore) Set(ctx context.Context, path string, values map[string]interface{}, ...) error
- func (f *Firestore) URI() string
- type LogLevel
- type Logger
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func SetContextLogger ¶
func SetContextLogger(l ContextLogger)
SetContextLogger sets logger for the package.
Types ¶
type ContextLogger ¶
type ContextLogger interface { Debugf(ctx context.Context, format string, args ...interface{}) Infof(ctx context.Context, format string, args ...interface{}) Warningf(ctx context.Context, format string, args ...interface{}) Errorf(ctx context.Context, format string, args ...interface{}) }
ContextLogger interface used in this package with request context.
type Firestore ¶
type Firestore struct {
// contains filtered or unexported fields
}
Firestore is a DocumentStore implemented on Google Cloud Firestore.
func New ¶
func New(uri string, opts ...option.ClientOption) (*Firestore, error)
New creates a Firestore
Example ¶
url := "firestore://chilltest-3297b" collection := "test" opts := []option.ClientOption{option.WithCredentialsFile("credentials.json")} fs, err := New(url, opts...) if err != nil { log.Fatal(err) } exists, err := fs.Exists(context.TODO(), dstore.Path(collection, "key1")) if err != nil { log.Fatal(err) } if exists { if _, err := fs.Delete(context.TODO(), dstore.Path(collection, "key1")); err != nil { log.Fatal(err) } } if err := fs.Create(context.TODO(), dstore.Path(collection, "key1"), dstore.Data([]byte("value1"))); err != nil { log.Fatal(err) } entry, err := fs.Get(context.TODO(), dstore.Path(collection, "key1")) if err != nil { log.Fatal(err) } fmt.Printf("%s\n", entry.Path) fmt.Printf("%s\n", entry.Data())
Output: /test/key1 value1
func (*Firestore) Collections ¶
Collections ...
func (*Firestore) Create ¶
Create document.
Paths can be nested as long as they are even length components. For example,
collection1/key1 (OK) collection1/key1/collection2/key2 (OK) collection1 (INVALID) collection1/key1/collection2 (INVALID)
func (*Firestore) DocumentIterator ¶
func (f *Firestore) DocumentIterator(ctx context.Context, parent string, opt ...dstore.Option) (dstore.Iterator, error)
DocumentIterator ...
func (*Firestore) Documents ¶
func (f *Firestore) Documents(ctx context.Context, parent string, opt ...dstore.Option) ([]*dstore.Document, error)
Documents not implemented on Firestore, use DocumentIterator.
func (*Firestore) EventPosition ¶
func (*Firestore) EventPositions ¶
func (f *Firestore) EventPositions(ctx context.Context, paths []string) (map[string]*events.Position, error)
EventPositions returns positions for event logs.
func (*Firestore) Events ¶
func (f *Firestore) Events(ctx context.Context, path string, opt ...events.Option) (events.Iterator, error)
Events ...
func (*Firestore) EventsDelete ¶
EventsDelete removes events.
func (*Firestore) Set ¶
func (f *Firestore) Set(ctx context.Context, path string, values map[string]interface{}, opt ...dstore.SetOption) error
Set document. Will create or set, overwriting any existing data.
Paths can be nested as long as they are even length components. For example,
collection1/key1 (OK) collection1/key1/collection2/key2 (OK) collection1 (INVALID) collection1/key1/collection2 (INVALID)