File tree Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Expand file tree Collapse file tree 2 files changed +21
-1
lines changed Original file line number Diff line number Diff 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 }
Original file line number Diff line number Diff line change @@ -5010,6 +5010,26 @@ 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+
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+
50135033 it ( 'can run count query using aggregate api' , async ( ) => {
50145034 const testDocs = {
50155035 a : { author : 'authorA' , title : 'titleA' } ,
You can’t perform that action at this time.
0 commit comments