File tree 2 files changed +21
-1
lines changed
2 files changed +21
-1
lines changed Original file line number Diff line number Diff line change @@ -335,7 +335,7 @@ export class AggregateQuery<
335
335
if ( transactionOrReadTime instanceof Uint8Array ) {
336
336
runQueryRequest . transaction = transactionOrReadTime ;
337
337
} else if ( transactionOrReadTime instanceof Timestamp ) {
338
- runQueryRequest . readTime = transactionOrReadTime ;
338
+ runQueryRequest . readTime = transactionOrReadTime . toProto ( ) . timestampValue ;
339
339
} else if ( transactionOrReadTime ) {
340
340
runQueryRequest . newTransaction = transactionOrReadTime ;
341
341
}
Original file line number Diff line number Diff line change @@ -5010,6 +5010,26 @@ describe('Aggregation queries', () => {
5010
5010
return Promise . all ( sets ) ;
5011
5011
}
5012
5012
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
+
5017
+ const count = await firestore . runTransaction ( t => t . get ( col . count ( ) ) , {
5018
+ readOnly : true ,
5019
+ readTime : writeResult . writeTime ,
5020
+ } ) ;
5021
+ expect ( count . data ( ) . count ) . to . equal ( 1 ) ;
5022
+
5023
+ const countBefore = await firestore . runTransaction (
5024
+ t => t . get ( col . count ( ) ) ,
5025
+ {
5026
+ readOnly : true ,
5027
+ readTime : Timestamp . fromMillis ( writeResult . writeTime . toMillis ( ) - 1 ) ,
5028
+ }
5029
+ ) ;
5030
+ expect ( countBefore . data ( ) . count ) . to . equal ( 0 ) ;
5031
+ } ) ;
5032
+
5013
5033
it ( 'can run count query using aggregate api' , async ( ) => {
5014
5034
const testDocs = {
5015
5035
a : { author : 'authorA' , title : 'titleA' } ,
You can’t perform that action at this time.
0 commit comments