database

package
Version: v0.0.0-...-139157c Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2020 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FireStoreHelper

type FireStoreHelper struct {
	Cxt             context.Context
	CredentialsFile string
}

func NewFireStoreHelper

func NewFireStoreHelper() *FireStoreHelper

NewFireStoreHelper returns the pointer to an empty FireStoreHelper

func (*FireStoreHelper) FireStoreDelete

func (helper *FireStoreHelper) FireStoreDelete(collectionName string, id string) (*firestore.WriteResult, error)

FireStoreDelete deletes a document from the specified collection and returns WriteResult and an error

func (*FireStoreHelper) FireStoreGetAll

func (helper *FireStoreHelper) FireStoreGetAll(name string) ([]*firestore.DocumentSnapshot, error)

FireStoreGetAll returns all documents from a collection

func (*FireStoreHelper) FireStoreGetByID

func (helper *FireStoreHelper) FireStoreGetByID(collection string, docID string) (*firestore.DocumentSnapshot, error)

FireStoreGetByID returns a document from a collection search by ID Use Data() method on returned DocumentSnapshot object to retrieve the data as map

func (*FireStoreHelper) FireStoreGetByQuery

func (helper *FireStoreHelper) FireStoreGetByQuery(collection string, field string, opstring string, value string) ([]*firestore.DocumentSnapshot, error)

FireStoreGetByQuery returns a document from a collection using a query on a field Example: FireStoreGetByQuery("collection", "name", "==", "James")

func (*FireStoreHelper) FireStoreGetCollection

func (helper *FireStoreHelper) FireStoreGetCollection(name string) error

GetCollection returns pointer to firestore.CollectionRef if the requested collection exists exists else an error

func (*FireStoreHelper) FireStoreInsert

func (helper *FireStoreHelper) FireStoreInsert(collectionName string, id string, doc map[string]interface{}) (*firestore.WriteResult, error)

FireStoreInsert inserts a JSON document to the specified collection and returns WriteResult and an error

func (*FireStoreHelper) FireStoreUpdate

func (helper *FireStoreHelper) FireStoreUpdate(collectionName string, id string, doc map[string]interface{}) (*firestore.WriteResult, error)

FireStoreUpdate updates a JSON document to the specified collection and returns WriteResult and an error

func (*FireStoreHelper) GetLocalClient

func (helper *FireStoreHelper) GetLocalClient() (*firestore.Client, error)

GetLocalClient initializes Google Admin SDK client if code is being executed outside of google cloud.

func (*FireStoreHelper) WithContext

func (helper *FireStoreHelper) WithContext(cxt context.Context) *FireStoreHelper

WithContext helps in initializing a FireStoreHelper with context

func (*FireStoreHelper) WithCredsFile

func (helper *FireStoreHelper) WithCredsFile(filename string) *FireStoreHelper

WithContext helps in initializing a FireStoreHelper with Credentials file which hold service Account Information

Source Files

Jump to

Keyboard shortcuts

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