firestore

package
v2.0.3 Latest Latest
Warning

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

Go to latest
Published: May 24, 2023 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package firestore contains data structures and helper functions for using firebase firestore.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyQuery

func ApplyQuery(col *firestore.CollectionRef,
	query datastore.Query) firestore.Query

ApplyQuery takes collection reference and a custom query and applies the query to the collection reference.

func Or

func Or[O any](ctx context.Context, concurrentQueries int, bufferSize int,
	t *firestore.Transaction, col *firestore.CollectionRef,
	queries ...datastore.Query) (<-chan O, <-chan error)

Or takes a set of datastore queries, and runs them concurrently under the same transaction, and then collates all the results. Effectively simulating an OR query.

Params concurrentQueries and bufferSize helps control the overall performance. concurrentQueries controls how many queries would run concurrently. If this is fewer than the total number of queries, queries would queue up and some queries would execute after previous ones finish. bufferSize controls the size of the result buffer for each query. If this value is too small, queries will also have to wait until results have been read from the buffer.

Applications should carefully tune these two params, as values too small would cause contention, and values too large could cause excessive resource consumption.

Due to the fact that this is a simulated OR query, users of the function should be aware of the following limitations:

  1. Ordering will not work. Since different queries are run separately concurrently and their results are streamed into the output channel, the ordering of the results could be arbitrary. If ordering is required, users will need to read all the results and then perform any sorting required on the completed result set.
  2. Limit query will not work. Due to the same reason why ordering does not work.

As a workaround, users should read all the results, apply any sorting, further filtering, and limiting of the results in their own code.

Types

This section is empty.

Jump to

Keyboard shortcuts

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