fstore

package
v0.0.0-...-10bebe8 Latest Latest
Warning

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

Go to latest
Published: May 6, 2024 License: BSD-3-Clause Imports: 6 Imported by: 0

Documentation

Overview

Package fstore provides general support for Firestore. Its main feature is separate namespaces, to mimic separate databases for different purposes (prod, dev, test, etc.).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode[T any](ds *firestore.DocumentSnapshot) (*T, error)

Decode decodes a DocumentSnapshot into a value of type T.

func Get

func Get[T any](ctx context.Context, dr *firestore.DocumentRef) (_ *T, err error)

Get gets the DocumentRef and decodes the result to a value of type T.

func Set

func Set[T any](ctx context.Context, dr *firestore.DocumentRef, value *T) (err error)

Set sets the DocumentRef to the value.

Types

type Namespace

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

A Namespace is a top-level collection for partitioning a Firestore database into separate segments.

func OpenNamespace

func OpenNamespace(ctx context.Context, projectID, name string) (_ *Namespace, err error)

OpenNamespace creates a new Firestore client whose collections will be located in the given namespace.

func (*Namespace) Client

func (ns *Namespace) Client() *firestore.Client

Client returns the underlying Firestore client.

func (*Namespace) Close

func (ns *Namespace) Close() error

Close closes the underlying client.

func (*Namespace) Collection

func (ns *Namespace) Collection(name string) *firestore.CollectionRef

Collection returns a reference to the named collection in the namespace.

func (*Namespace) Name

func (ns *Namespace) Name() string

Name returns the Namespace's name.

Jump to

Keyboard shortcuts

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