Skip to content

Commit b818ec9

Browse files
Index-Free: Track readTime in the RemoteDocument store (#2125)
1 parent 3426035 commit b818ec9

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

packages/firestore/src/local/indexeddb_schema.ts

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,13 @@ export class SchemaConverter implements SimpleDbSchemaConverter {
138138

139139
if (fromVersion < 9 && toVersion >= 9) {
140140
p = p.next(() => {
141+
<<<<<<< HEAD
141142
// Multi-Tab used to manage its own changelog, but this has been moved
142143
// to the DbRemoteDocument object store itself. Since the previous change
143144
// log only contained transient data, we can drop its object store.
144145
dropRemoteDocumentChangesStore(db);
146+
=======
147+
>>>>>>> b4d70ace... Index-Free: Track readTime in the RemoteDocument store (#2125)
145148
createRemoteDocumentReadTimeIndex(txn);
146149
});
147150
}
@@ -610,6 +613,7 @@ export class DbRemoteDocument {
610613
static store = 'remoteDocuments';
611614

612615
/**
616+
<<<<<<< HEAD
613617
* An index that provides access to all entries sorted by read time (which
614618
* corresponds to the last modification time of each row).
615619
*
@@ -620,6 +624,8 @@ export class DbRemoteDocument {
620624
static readTimeIndexPath = 'readTime';
621625

622626
/**
627+
=======
628+
>>>>>>> b4d70ace... Index-Free: Track readTime in the RemoteDocument store (#2125)
623629
* An index that provides access to documents in a collection sorted by read
624630
* time.
625631
*
@@ -997,6 +1003,19 @@ function createRemoteDocumentReadTimeIndex(txn: IDBTransaction): void {
9971003
);
9981004
}
9991005

1006+
/**
1007+
* Creates indices on the RemoteDocuments store used for both multi-tab
1008+
* and Index-Free queries.
1009+
*/
1010+
function createRemoteDocumentReadTimeIndex(txn: IDBTransaction): void {
1011+
const remoteDocumentStore = txn.objectStore(DbRemoteDocument.store);
1012+
remoteDocumentStore.createIndex(
1013+
DbRemoteDocument.collectionReadTimeIndex,
1014+
DbRemoteDocument.collectionReadTimeIndexPath,
1015+
{ unique: false }
1016+
);
1017+
}
1018+
10001019
/**
10011020
* A record of the metadata state of each client.
10021021
*

packages/firestore/src/local/local_serializer.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,11 +123,14 @@ export class LocalSerializer {
123123
return [timestamp.seconds, timestamp.nanoseconds];
124124
}
125125

126+
<<<<<<< HEAD
126127
fromDbTimestampKey(dbTimestampKey: DbTimestampKey): SnapshotVersion {
127128
const timestamp = new Timestamp(dbTimestampKey[0], dbTimestampKey[1]);
128129
return SnapshotVersion.fromTimestamp(timestamp);
129130
}
130131

132+
=======
133+
>>>>>>> b4d70ace... Index-Free: Track readTime in the RemoteDocument store (#2125)
131134
private toDbTimestamp(snapshotVersion: SnapshotVersion): DbTimestamp {
132135
const timestamp = snapshotVersion.toTimestamp();
133136
return new DbTimestamp(timestamp.seconds, timestamp.nanoseconds);

packages/firestore/src/local/local_store.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,9 +450,13 @@ export class LocalStore {
450450
* queue.
451451
*/
452452
applyRemoteEvent(remoteEvent: RemoteEvent): Promise<MaybeDocumentMap> {
453+
<<<<<<< HEAD
453454
const documentBuffer = this.remoteDocuments.newChangeBuffer({
454455
createSentinelDocumentsToTrackDeletes: true
455456
});
457+
=======
458+
const documentBuffer = this.remoteDocuments.newChangeBuffer();
459+
>>>>>>> b4d70ace... Index-Free: Track readTime in the RemoteDocument store (#2125)
456460
const remoteVersion = remoteEvent.snapshotVersion;
457461
return this.persistence.runTransaction(
458462
'Apply remote event',

0 commit comments

Comments
 (0)