Skip to content

Commit 2777cc0

Browse files
committed
Fix timestamp bug
1 parent 5937b93 commit 2777cc0

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

dev/src/reference/aggregate-query.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,7 @@ export class AggregateQuery<
335335
if (transactionOrReadTime instanceof Uint8Array) {
336336
runQueryRequest.transaction = transactionOrReadTime;
337337
} else if (transactionOrReadTime instanceof Timestamp) {
338-
runQueryRequest.readTime = transactionOrReadTime;
338+
runQueryRequest.readTime = transactionOrReadTime.toProto().timestampValue;
339339
} else if (transactionOrReadTime) {
340340
runQueryRequest.newTransaction = transactionOrReadTime;
341341
}

dev/system-test/firestore.ts

+10
Original file line numberDiff line numberDiff line change
@@ -5010,6 +5010,16 @@ describe('Aggregation queries', () => {
50105010
return Promise.all(sets);
50115011
}
50125012

5013+
it('can run count within a transaction with readtime', async () => {
5014+
const doc = col.doc();
5015+
const writeResult: WriteResult = await doc.create({some: 'data'});
5016+
const count = await firestore.runTransaction(t => t.get(col.count()), {
5017+
readOnly: true,
5018+
readTime: writeResult.writeTime,
5019+
});
5020+
expect(count.data().count).to.equal(1);
5021+
});
5022+
50135023
it('can run count query using aggregate api', async () => {
50145024
const testDocs = {
50155025
a: {author: 'authorA', title: 'titleA'},

0 commit comments

Comments
 (0)