Documentation

Overview

Package firestore implements dstore.Documents backed by firestore.

Index

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.

func NewContextLogger

func NewContextLogger(lev LogLevel) ContextLogger

NewContextLogger ...

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
Output:

/test/key1
value1

func (*Firestore) Collections

func (f *Firestore) Collections(ctx context.Context, parent string) ([]*dstore.Collection, error)

Collections ...

func (*Firestore) Create

func (f *Firestore) Create(ctx context.Context, path string, values map[string]interface{}) error

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) Delete

func (f *Firestore) Delete(ctx context.Context, path string) (bool, error)

Delete ...

func (*Firestore) DeleteAll

func (f *Firestore) DeleteAll(ctx context.Context, paths []string) error

DeleteAll ...

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) 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) EventsAdd

func (f *Firestore) EventsAdd(ctx context.Context, path string, data [][]byte) ([]*events.Event, int64, error)

EventsAdd adds events.

func (*Firestore) EventsDelete

func (f *Firestore) EventsDelete(ctx context.Context, path string) (bool, error)

EventsDelete removes events.

func (*Firestore) Exists

func (f *Firestore) Exists(ctx context.Context, path string) (bool, error)

Exists returns true if path exists.

func (*Firestore) Get

func (f *Firestore) Get(ctx context.Context, path string) (*dstore.Document, error)

Get ...

func (*Firestore) GetAll

func (f *Firestore) GetAll(ctx context.Context, paths []string) ([]*dstore.Document, error)

GetAll paths.

func (*Firestore) Increment

func (f *Firestore) Increment(ctx context.Context, path string, name string, n int64) (int64, int64, error)

Increment is a very slow increment by. Limited to 1 write a second. Returns start of index. If we need better performance we can shard. TODO: https://firebase.google.com/docs/firestore/solutions/counters#go

func (*Firestore) Load

func (f *Firestore) Load(ctx context.Context, path string, v interface{}) (bool, error)

Load path into value.

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)

func (*Firestore) URI

func (f *Firestore) URI() string

URI ...

type LogLevel

type LogLevel int

LogLevel ...

const (
	// DebugLevel ...
	DebugLevel LogLevel = 3
	// InfoLevel ...
	InfoLevel LogLevel = 2
	// WarnLevel ...
	WarnLevel LogLevel = 1
	// ErrLevel ...
	ErrLevel LogLevel = 0
)

type Logger

type Logger interface {
	Debugf(format string, args ...interface{})
	Infof(format string, args ...interface{})
	Warningf(format string, args ...interface{})
	Errorf(format string, args ...interface{})
	Fatalf(format string, args ...interface{})
}

Logger interface used in this package.

func NewLogger

func NewLogger(lev LogLevel) Logger

NewLogger ...