Skip to content

Commit

Permalink
RemoteDocumentCache APIs for Indexing (#5988)
Browse files Browse the repository at this point in the history
  • Loading branch information
schmidt-sebastian committed Mar 18, 2022
1 parent 911c028 commit 69aa7b0
Show file tree
Hide file tree
Showing 21 changed files with 815 additions and 289 deletions.
5 changes: 5 additions & 0 deletions .changeset/seven-dolphins-breathe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
"@firebase/firestore": patch
---

The format of some of the IndexedDB data changed. This increases the performance of document lookups after an initial migration. If you do not want to migrate data, you can call `clearIndexedDbPersistence()` before invoking `enableIndexedDbPersistence()`.
1 change: 1 addition & 0 deletions packages/firestore/externs.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
"packages/firestore/src/protos/firestore_proto_api.ts",
"packages/firestore/src/util/error.ts",
"packages/firestore/src/local/indexeddb_schema.ts",
"packages/firestore/src/local/indexeddb_schema_legacy.ts",
"packages/firestore/src/local/shared_client_state_schema.ts"
]
}
4 changes: 4 additions & 0 deletions packages/firestore/src/core/snapshot_version.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,10 @@ export class SnapshotVersion {
return new SnapshotVersion(new Timestamp(0, 0));
}

static max(): SnapshotVersion {
return new SnapshotVersion(new Timestamp(253402300799, 1e9 - 1));
}

private constructor(private timestamp: Timestamp) {}

compareTo(other: SnapshotVersion): number {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
DbMutationBatch,
DbRemoteDocument
} from './indexeddb_schema';
import { DbRemoteDocument as DbRemoteDocumentLegacy } from './indexeddb_schema_legacy';
import {
DbDocumentMutationKey,
DbDocumentMutationStore,
Expand Down Expand Up @@ -84,7 +85,9 @@ export function removeMutationBatch(
/**
* Returns an approximate size for the given document.
*/
export function dbDocumentSize(doc: DbRemoteDocument | null): number {
export function dbDocumentSize(
doc: DbRemoteDocument | DbRemoteDocumentLegacy | null
): number {
if (!doc) {
return 0;
}
Expand Down

0 comments on commit 69aa7b0

Please sign in to comment.