Documentation
¶
Index ¶
- type FirestoreBackend
- func (b *FirestoreBackend) Close()
- func (b *FirestoreBackend) CountEvents(ctx context.Context, filter nostr.Filter) (int64, error)
- func (b *FirestoreBackend) DeleteEvent(ctx context.Context, event *nostr.Event) error
- func (b *FirestoreBackend) Init() error
- func (b *FirestoreBackend) QueryEvents(ctx context.Context, filter nostr.Filter) (chan *nostr.Event, error)
- func (b *FirestoreBackend) ReplaceEvent(ctx context.Context, evt *nostr.Event) error
- func (b *FirestoreBackend) SaveEvent(ctx context.Context, event *nostr.Event) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type FirestoreBackend ¶
type FirestoreBackend struct {
sync.Mutex
*firestore.Client
// ProjectID is the Google Cloud project that owns the Firestore database.
// Required. Credentials come from Application Default Credentials, or from
// the FIRESTORE_EMULATOR_HOST environment variable when set.
ProjectID string
// DatabaseID selects a named Firestore database within the project.
// Defaults to "(default)".
DatabaseID string
// Collection is the Firestore collection events are stored in. Defaults to
// "events".
Collection string
// QueryLimit caps how many events a single QueryEvents call may return.
QueryLimit int
// PageSize is how many documents are fetched per Firestore round-trip while
// paging towards QueryLimit. Larger values mean fewer round-trips but more
// documents read when client-side filtering discards many of them.
PageSize int
}
FirestoreBackend is an eventstore.Store backed by Google Cloud Firestore (Native mode).
Firestore's query language is much more restrictive than SQL: a single query may only carry one disjunctive ("in" / "array-contains-any") clause and one range field, and every composite of equality/array + range + order-by needs a pre-declared composite index (see firestore.indexes.json). Because of that this backend pushes down only the created_at range plus the single most selective dimension of a nostr.Filter and enforces the remaining constraints client-side with filter.Matches, so results are always correct while the push-down keeps the number of billed document reads down.
func (*FirestoreBackend) Close ¶
func (b *FirestoreBackend) Close()
func (*FirestoreBackend) CountEvents ¶
func (*FirestoreBackend) DeleteEvent ¶
func (*FirestoreBackend) Init ¶
func (b *FirestoreBackend) Init() error