fsdb

package module
v0.0.0-...-fe9bcd1 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2024 License: BSD-2-Clause Imports: 11 Imported by: 1

README

fsdb

Firestore Database Wrapper

Documentation

Index

Constants

View Source
const (
	JoinCodeLength     = 6
	JoinCodeCharacters = "0123456789"
)

Variables

View Source
var DBIteratorDone = iterator.Done

Functions

func ErrorIsAlreadyExists

func ErrorIsAlreadyExists(err error) bool

func ErrorIsCanceled

func ErrorIsCanceled(err error) bool

func ErrorIsNotFound

func ErrorIsNotFound(err error) bool

Types

type CollectionIterator

type CollectionIterator struct {
	*firestore.CollectionIterator
}

type DBCollectionChanges

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

func (*DBCollectionChanges) Changes

func (c *DBCollectionChanges) Changes() []*DocumentChange

func (*DBCollectionChanges) Iterator

func (c *DBCollectionChanges) Iterator() *DocumentIterator

type DBConnection

type DBConnection struct {
	Client *firestore.Client
	// contains filtered or unexported fields
}

func NewDBConnection

func NewDBConnection(ctx context.Context, log logger.CompatLogWriter, project string, credentialsFile string) (*DBConnection, error)

func (*DBConnection) Add

func (db *DBConnection) Add(ctx context.Context, docname string, dval interface{}) error

func (*DBConnection) AddOrReplace

func (db *DBConnection) AddOrReplace(ctx context.Context, docname string, dval interface{}) error

func (*DBConnection) AtomicGetOrCreate

func (db *DBConnection) AtomicGetOrCreate(ctx context.Context, docname string, dval interface{}, createfunc DBCreateFunc) error

func (*DBConnection) AtomicUpdate

func (db *DBConnection) AtomicUpdate(ctx context.Context, docname string, dval interface{}, updateFunc DBUpdateFunc) error

func (*DBConnection) CollectionGroupAdd

func (db *DBConnection) CollectionGroupAdd(ctx context.Context, colname string, dval interface{}) error

* Adds a new [automatically named] document to a collection group

func (*DBConnection) CollectionGroupQuery

func (db *DBConnection) CollectionGroupQuery(ctx context.Context, colname string, wheres []*DbWhere) *DocumentIterator

func (*DBConnection) CollectionIterator

func (db *DBConnection) CollectionIterator(ctx context.Context, docname string) *CollectionIterator

func (*DBConnection) CollectionListen

func (db *DBConnection) CollectionListen(log logger.CompatLogWriter, ctx context.Context, collection string, handler func(changes *DBCollectionChanges) error, filter *ListenFilter) error

func (*DBConnection) Delete

func (db *DBConnection) Delete(ctx context.Context, docname string) error

func (*DBConnection) DocListen

func (db *DBConnection) DocListen(ctx context.Context, collection string, doc string, handler func(change *DocumentChange) error) error

func (*DBConnection) DocumentIterator

func (db *DBConnection) DocumentIterator(ctx context.Context, path string) *DocumentIterator

func (*DBConnection) Escape

func (db *DBConnection) Escape(raw string) string

func (*DBConnection) Get

func (db *DBConnection) Get(ctx context.Context, docname string, dval interface{}) error

func (*DBConnection) NextDoc

func (db *DBConnection) NextDoc(ctx context.Context, iter *DocumentIterator, dval interface{}) error

func (*DBConnection) NextDocPath

func (db *DBConnection) NextDocPath(ctx context.Context, iter *DocumentIterator, dval interface{}) (string, error)

func (*DBConnection) QueryIterator

func (db *DBConnection) QueryIterator(ctx context.Context, colname string, attr string, comparison string, val string) *DocumentIterator

func (*DBConnection) RunTransaction

func (db *DBConnection) RunTransaction(ctx context.Context, tfuncs ...TransactionFunc) error

func (*DBConnection) Unescape

func (db *DBConnection) Unescape(s string) string

type DBCreateFunc

type DBCreateFunc func(ctx context.Context, dval interface{}) error

type DBUpdateFunc

type DBUpdateFunc func(ctx context.Context, dval interface{}) error

type DbWhere

type DbWhere struct {
	Attr       string
	Comparison string
	Val        string
}

type DocumentChange

type DocumentChange struct {
	Kind DocumentChangeKind
	Path string
	// contains filtered or unexported fields
}

func (*DocumentChange) Data

func (dc *DocumentChange) Data() map[string]interface{}

func (*DocumentChange) DataTo

func (dc *DocumentChange) DataTo(dval interface{}) error

type DocumentChangeKind

type DocumentChangeKind int
const (
	DBCHANGE_ERROR DocumentChangeKind = iota
	DBCHANGE_DOC_ADDED
	DBCHANGE_DOC_REMOVED
	DBCHANGE_DOC_CHANGED
)

func (DocumentChangeKind) ToString

func (k DocumentChangeKind) ToString() string

type DocumentIterator

type DocumentIterator struct {
	*firestore.DocumentIterator
}

type JoinCode

type JoinCode struct {
	Code  string
	MgrID string
	UID   string
	Data  map[string]any
}

func JoinCodeCreate

func JoinCodeCreate(mgrid string, t *Transaction, uid string, data map[string]any) (*JoinCode, error)

func JoinCodeLookupByCode

func JoinCodeLookupByCode(t *Transaction, code string) (*JoinCode, error)

func JoinCodeLookupByUID

func JoinCodeLookupByUID(mgrid string, t *Transaction, uid string) (*JoinCode, error)

func ListJoinCodes

func ListJoinCodes(t *Transaction) ([]*JoinCode, error)

func (*JoinCode) Delete

func (jc *JoinCode) Delete(t *Transaction) error

func (*JoinCode) Save

func (jc *JoinCode) Save(t *Transaction) error

type ListenFilter

type ListenFilter struct {
	Path  string
	Op    string
	Value interface{}
}

type Transaction

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

func (*Transaction) Add

func (t *Transaction) Add(docname string, dval interface{}) error

func (*Transaction) AddOrReplace

func (t *Transaction) AddOrReplace(docname string, dval interface{}) error

func (*Transaction) Delete

func (t *Transaction) Delete(docname string) error

func (*Transaction) DocumentIterator

func (t *Transaction) DocumentIterator(colname string) *DocumentIterator

func (*Transaction) Escape

func (t *Transaction) Escape(raw string) string

func (*Transaction) Get

func (t *Transaction) Get(docname string, dval interface{}) error

func (*Transaction) NextDocPath

func (t *Transaction) NextDocPath(iter *DocumentIterator, dval interface{}) (string, error)

func (*Transaction) QueryIterator

func (t *Transaction) QueryIterator(colname string, attr string, comparison string, val string) *DocumentIterator

type TransactionFunc

type TransactionFunc func(ctx context.Context, t *Transaction) error

Jump to

Keyboard shortcuts

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