store

package
v0.2.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 26, 2021 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ErrDataNotFound when there query found no data
	ErrDataNotFound = "data not found"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	// ProjectID is the ID of the project.
	ProjectID string `json:"project_id"`
}

Config represens store configuration.

type GetID

type GetID func(item interface{}) string

type MakeNew

type MakeNew func() interface{}

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store represents the generic FB store

func New

func New(ctx context.Context, configContent []byte, logger *log.Logger) (*Store, error)

New creates a new Store

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, col, id string) error

Delete deletes specific record using its ID as key

func (*Store) Get

func (s *Store) Get(ctx context.Context, col, id string, in interface{}) error

Get gets specific record using its ID as key

func (*Store) GetAll

func (s *Store) GetAll(ctx context.Context, col string, maker MakeNew) ([]interface{}, error)

GetAll returns all records in that collection

func (*Store) GetClient

func (s *Store) GetClient() *firestore.Client

GetClient gives external packages access to the Firestore client.

func (*Store) GetCollection

func (s *Store) GetCollection(name string) (col *firestore.CollectionRef, err error)

GetCollection gives external packages access to the specific Firestore collection by name.

func (*Store) Save

func (s *Store) Save(ctx context.Context, col, id string, in interface{}) error

Save saves in struct instance with ID as key

func (*Store) SaveAll

func (s *Store) SaveAll(ctx context.Context, col string, g GetID, items []interface{}) error

SaveAll saves all items in a transaction.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL