firestore

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: May 25, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Overview

Package firestore provides an in-memory mock implementation of Google Cloud Firestore.

Index

Constants

View Source
const (
	OpEqual        = "="
	OpNotEqual     = "!="
	OpLessThan     = "<"
	OpGreaterThan  = ">"
	OpLessEqual    = "<="
	OpGreaterEqual = ">="
	OpContains     = "CONTAINS"
	OpBeginsWith   = "BEGINS_WITH"
	OpBetween      = "BETWEEN"
)

Scan/query filter operator constants.

View Source
const (
	ViewNewImage  = "NEW_IMAGE"
	ViewOldImage  = "OLD_IMAGE"
	ViewNewAndOld = "NEW_AND_OLD_IMAGES"
	ViewKeysOnly  = "KEYS_ONLY"
)

Snapshot and TTL constants.

Variables

This section is empty.

Functions

This section is empty.

Types

type Mock

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

Mock is an in-memory mock implementation of Google Cloud Firestore.

func New

func New(opts *config.Options) *Mock

New creates a new Firestore mock.

func (*Mock) BatchGetItems

func (m *Mock) BatchGetItems(_ context.Context, table string, keys []map[string]any) ([]map[string]any, error)

func (*Mock) BatchPutItems

func (m *Mock) BatchPutItems(_ context.Context, table string, items []map[string]any) error

func (*Mock) CreateIndex added in v1.4.0

func (m *Mock) CreateIndex(_ context.Context, table string, cfg driver.GSIConfig) (*driver.IndexInfo, error)

CreateIndex creates a composite index on a collection.

func (*Mock) CreateTable

func (m *Mock) CreateTable(_ context.Context, cfg driver.TableConfig) error

func (*Mock) DeleteIndex added in v1.4.0

func (m *Mock) DeleteIndex(_ context.Context, table, indexName string) error

DeleteIndex removes a composite index from a collection.

func (*Mock) DeleteItem

func (m *Mock) DeleteItem(ctx context.Context, table string, key map[string]any) error

func (*Mock) DeleteTable

func (m *Mock) DeleteTable(_ context.Context, name string) error

func (*Mock) DescribeIndex added in v1.4.0

func (m *Mock) DescribeIndex(_ context.Context, table, indexName string) (*driver.IndexInfo, error)

DescribeIndex returns information about a composite index.

func (*Mock) DescribeTTL added in v1.2.0

func (m *Mock) DescribeTTL(_ context.Context, table string) (*driver.TTLConfig, error)

DescribeTTL returns the TTL configuration for a collection.

func (*Mock) DescribeTable

func (m *Mock) DescribeTable(_ context.Context, name string) (*driver.TableConfig, error)

func (*Mock) GetItem

func (m *Mock) GetItem(ctx context.Context, table string, key map[string]any) (map[string]any, error)

func (*Mock) GetStreamRecords added in v1.2.0

func (m *Mock) GetStreamRecords(
	_ context.Context, table string, limit int, token string,
) (*driver.StreamIterator, error)

GetStreamRecords returns snapshot records after the given token.

func (*Mock) ListIndexes added in v1.4.0

func (m *Mock) ListIndexes(_ context.Context, table string) ([]driver.IndexInfo, error)

ListIndexes returns all composite indexes for a collection.

func (*Mock) ListTables

func (m *Mock) ListTables(_ context.Context) ([]string, error)

func (*Mock) ListTagsOfResource added in v1.6.4

func (m *Mock) ListTagsOfResource(_ context.Context, table string) (map[string]string, error)

ListTagsOfResource returns a copy of the label map for a collection.

func (*Mock) PutItem

func (m *Mock) PutItem(ctx context.Context, table string, item map[string]any) error

func (*Mock) Query

func (m *Mock) Query(ctx context.Context, input driver.QueryInput) (*driver.QueryResult, error)

func (*Mock) Scan

func (m *Mock) Scan(ctx context.Context, input driver.ScanInput) (*driver.QueryResult, error)

func (*Mock) SetMonitoring added in v1.2.0

func (m *Mock) SetMonitoring(mon mondriver.Monitoring)

SetMonitoring sets the monitoring backend for auto-metric generation.

func (*Mock) TagResource added in v1.6.4

func (m *Mock) TagResource(_ context.Context, table string, tags map[string]string) error

TagResource sets or replaces label key/values on a collection. GCP terms these "labels"; the cross-cloud driver interface calls the method TagResource. Existing labels not present in tags are preserved; existing labels present in tags are overwritten.

func (*Mock) TransactWriteItems added in v1.2.0

func (m *Mock) TransactWriteItems(
	_ context.Context, table string, puts []map[string]any, deletes []map[string]any,
) error

TransactWriteItems executes puts and deletes atomically.

func (*Mock) UntagResource added in v1.6.4

func (m *Mock) UntagResource(_ context.Context, table string, tagKeys []string) error

UntagResource removes the given label keys from a collection. Unknown keys are ignored.

func (*Mock) UpdateItem added in v1.3.1

func (m *Mock) UpdateItem(ctx context.Context, input driver.UpdateItemInput) (map[string]any, error)

UpdateItem applies partial updates to an existing document in a collection.

func (*Mock) UpdateStreamConfig added in v1.2.0

func (m *Mock) UpdateStreamConfig(_ context.Context, table string, cfg driver.StreamConfig) error

UpdateStreamConfig configures real-time listeners for a collection.

func (*Mock) UpdateTTL added in v1.2.0

func (m *Mock) UpdateTTL(_ context.Context, table string, cfg driver.TTLConfig) error

UpdateTTL configures TTL for a collection.

Jump to

Keyboard shortcuts

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