Skip to content

Add Firestore backend#70

Merged
mattn merged 2 commits into
fiatjaf:masterfrom
mattn:firestore-backend
Jul 3, 2026
Merged

Add Firestore backend#70
mattn merged 2 commits into
fiatjaf:masterfrom
mattn:firestore-backend

Conversation

@mattn

@mattn mattn commented Jul 3, 2026

Copy link
Copy Markdown
Collaborator

Adds a Firestore (Native mode) backend implementing eventstore.Store and eventstore.Counter, in the same shape as the DynamoDB backend. Since Firestore allows only one disjunctive (in / array-contains-any) clause and one range field per query, QueryEvents pushes down the created_at range plus the single most selective dimension (ids, one tag, authors, or kinds) and enforces the rest client-side with filter.Matches, so results stay correct while reads stay bounded. CountEvents uses native aggregation when the filter is fully pushable and otherwise counts matches. Single-letter tags are flattened into a tagvalues array; content/sig/raw tags are index-exempt to keep index storage down. Required composite indexes are in firestore/firestore.indexes.json, and DatabaseID selects a named database. Includes unit tests plus a build-tagged integration test verified against a live Firestore project.

mattn added 2 commits July 3, 2026 17:50
Firestore (Native mode) implementation of eventstore.Store and Counter.

Because Firestore allows only one disjunctive (in / array-contains-any)
clause and one range field per query, QueryEvents pushes down the
created_at range plus the single most selective dimension (ids > tag >
authors > kinds) and enforces the rest client-side with filter.Matches,
so results are always correct while reads stay bounded. CountEvents uses
native aggregation when the filter is fully pushable, else counts matches.

Indexable single-letter tags are flattened into a tagvalues array;
content/sig/raw-tags are index-exempt to keep index storage down.
Composite indexes and exemptions are in firestore.indexes.json.
Add a DatabaseID field and use NewClientWithDatabase so a backend can
target a named Firestore database; defaults to "(default)". Point the
integration test at the "nostr-events" collection.
@mattn mattn merged commit b4b2855 into fiatjaf:master Jul 3, 2026
1 check passed
@mattn mattn deleted the firestore-backend branch July 3, 2026 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant