firestore_utils

package module
v0.0.0-...-490999a Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2019 License: MIT Imports: 8 Imported by: 0

README

firestore-utils

Utility Library for Firestore

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyToCollection

func ApplyToCollection(ctx context.Context, collectionName string, filterFunc Filter, transformFunc Transform) (bool, error)

ApplyToCollection applies Filter function to each doc, if true then applies Transform to the doc

func CreateFirestoreClientFromConfig

func CreateFirestoreClientFromConfig(ctx context.Context) (*firestore.Client, error)

CreateFirestoreClientFromConfig creates a firestore client from config

func FilterCollectionDocs

func FilterCollectionDocs(ctx context.Context, collectionName string, filterFunc Filter) ([]*firestore.DocumentSnapshot, error)

FilterCollectionDocs applies a Filter func to all the docs and returns the array of filtered ones

func TransformCollectionDocs

func TransformCollectionDocs(ctx context.Context, collectionName string, transformFunc Transform) (bool, error)

TransformCollectionDocs applies Transform function to each doc of the collection

func WriteCollectionToJSON

func WriteCollectionToJSON(ctx context.Context, collectionName string) (bool, error)

WriteCollectionToJSON write a collection as json with same name as collection

func WriteJSONtoCollection

func WriteJSONtoCollection(ctx context.Context, jsonPath string, collectionName string) (bool, error)

WriteJSONtoCollection reads a json file and writes to collection

func WriteToFirestore

func WriteToFirestore(ctx context.Context, data []map[string]interface{}, collectionName string, docIDFieldName string) (bool, error)

WriteToFirestore takes data as map[string]interface{} and writes to Firestore collection Will replace any doc if ID in the data already present in Firestore

Types

type Filter

type Filter func(snapshot *firestore.DocumentSnapshot) bool

type Transform

type Transform func(data map[string]interface{}) map[string]interface{}

Jump to

Keyboard shortcuts

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