@@ -314,9 +314,7 @@ const nsDocRef = nsColl.doc('alice');
314314const nsQuery = nsColl . where ( 'name' , '==' , 'test' ) ;
315315
316316nsDocRef . set ( { name : 'Alice' , count : 1 } ) . then ( ( ) => { } ) ;
317- nsDocRef
318- . set ( { name : 'Alice' } , { merge : true } )
319- . then ( ( ) => { } ) ;
317+ nsDocRef . set ( { name : 'Alice' } , { merge : true } ) . then ( ( ) => { } ) ;
320318
321319nsDocRef . update ( { count : 2 } ) . then ( ( ) => { } ) ;
322320nsDocRef . update ( 'count' , 3 ) . then ( ( ) => { } ) ;
@@ -401,13 +399,15 @@ void nsLoadTask.then(() => {});
401399const nsNamed = nsFirestore . namedQuery ( 'my-query' ) ;
402400void nsNamed ;
403401
404- nsFirestore . runTransaction ( async ( tx : FirebaseFirestoreTypes . Transaction ) => {
405- const snap = await tx . get ( nsDocRef ) ;
406- if ( snap . exists ( ) ) {
407- tx . update ( nsDocRef , { count : ( ( snap . data ( ) as { count ?: number } ) ?. count ?? 0 ) + 1 } ) ;
408- }
409- return null ;
410- } ) . then ( ( ) => { } ) ;
402+ nsFirestore
403+ . runTransaction ( async ( tx : FirebaseFirestoreTypes . Transaction ) => {
404+ const snap = await tx . get ( nsDocRef ) ;
405+ if ( snap . exists ( ) ) {
406+ tx . update ( nsDocRef , { count : ( ( snap . data ( ) as { count ?: number } ) ?. count ?? 0 ) + 1 } ) ;
407+ }
408+ return null ;
409+ } )
410+ . then ( ( ) => { } ) ;
411411
412412// ----- Firestore instance: persistence and network -----
413413nsFirestore . clearPersistence ( ) . then ( ( ) => { } ) ;
@@ -452,13 +452,15 @@ const nsArrayRemove = firebase.firestore.FieldValue.arrayRemove(1);
452452void nsArrayRemove ;
453453const nsIncrement = firebase . firestore . FieldValue . increment ( 1 ) ;
454454
455- nsDocRef . set ( {
456- name : 'x' ,
457- deleted : nsDelete ,
458- ts : nsServerTs ,
459- arr : nsArrayUnion ,
460- cnt : nsIncrement ,
461- } ) . then ( ( ) => { } ) ;
455+ nsDocRef
456+ . set ( {
457+ name : 'x' ,
458+ deleted : nsDelete ,
459+ ts : nsServerTs ,
460+ arr : nsArrayUnion ,
461+ cnt : nsIncrement ,
462+ } )
463+ . then ( ( ) => { } ) ;
462464
463465// ----- withConverter (namespaced) -----
464466interface User {
@@ -481,7 +483,6 @@ nsDocWithConv.get().then((snap: FirebaseFirestoreTypes.DocumentSnapshot<User>) =
481483 if ( u ) void [ u . name , u . age ] ;
482484} ) ;
483485
484-
485486// ----- getFirestore -----
486487const modFirestore1 = getFirestore ( ) ;
487488void modFirestore1 . app . name ;
@@ -970,10 +971,7 @@ const pipelineUnion = pipelineDb
970971 . collection ( 'cities/sf/restaurants' )
971972 . where ( field ( 'type' ) . equal ( 'Chinese' ) )
972973 . union (
973- pipelineDb
974- . pipeline ( )
975- . collection ( 'cities/ny/restaurants' )
976- . where ( field ( 'type' ) . equal ( 'Italian' ) ) ,
974+ pipelineDb . pipeline ( ) . collection ( 'cities/ny/restaurants' ) . where ( field ( 'type' ) . equal ( 'Italian' ) ) ,
977975 )
978976 . where ( field ( 'rating' ) . greaterThanOrEqual ( 4.5 ) )
979977 . sort ( field ( '__name__' ) . descending ( ) ) ;
@@ -984,10 +982,7 @@ const pipelineWithTransforms = pipelineDb
984982 . collection ( 'books' )
985983 . where (
986984 pipelineOr (
987- pipelineAnd (
988- field ( 'rating' ) . greaterThan ( 4 ) ,
989- lessThan ( field ( 'price' ) , constant ( 10 ) ) ,
990- ) ,
985+ pipelineAnd ( field ( 'rating' ) . greaterThan ( 4 ) , lessThan ( field ( 'price' ) , constant ( 10 ) ) ) ,
991986 field ( 'genre' ) . equal ( 'Fantasy' ) ,
992987 ) ,
993988 )
@@ -996,9 +991,7 @@ const pipelineWithTransforms = pipelineDb
996991 . select (
997992 field ( 'fullTitle' ) ,
998993 field ( 'rating' ) . greaterThan ( 4 ) . as ( 'isTopRated' ) ,
999- arrayContainsAny ( field ( 'genre' ) , [ 'Fantasy' , constant ( 'Sci-Fi' ) ] ) . as (
1000- 'matchesGenre' ,
1001- ) ,
994+ arrayContainsAny ( field ( 'genre' ) , [ 'Fantasy' , constant ( 'Sci-Fi' ) ] ) . as ( 'matchesGenre' ) ,
1002995 )
1003996 . sort ( Ordering . of ( field ( 'rating' ) ) . descending ( ) , field ( '__name__' ) . ascending ( ) )
1004997 . offset ( 1 )
@@ -1015,22 +1008,22 @@ const pipelineAggregateDistinct = pipelineDb
10151008 pipelineAverage ( 'population' ) . as ( 'populationAvg' ) ,
10161009 maximum ( 'population' ) . as ( 'populationMax' ) ,
10171010 ] ,
1018- groups : [
1019- field ( 'country' ) . as ( 'country' ) ,
1020- toLower ( field ( 'state' ) ) . as ( 'normalizedState' ) ,
1021- ] ,
1011+ groups : [ field ( 'country' ) . as ( 'country' ) , toLower ( field ( 'state' ) ) . as ( 'normalizedState' ) ] ,
10221012 } )
10231013 . where ( field ( 'populationTotal' ) . greaterThan ( 1000 ) )
10241014 . distinct ( field ( 'normalizedState' ) , 'country' ) ;
10251015void pipelineAggregateDistinct ;
10261016
1027- const pipelineFindNearest = pipelineDb . pipeline ( ) . collection ( 'cities' ) . findNearest ( {
1028- field : 'embedding' ,
1029- vectorValue : [ 1.5 , 2.345 ] ,
1030- distanceMeasure : 'COSINE' ,
1031- distanceField : 'computedDistance' ,
1032- limit : 10 ,
1033- } ) ;
1017+ const pipelineFindNearest = pipelineDb
1018+ . pipeline ( )
1019+ . collection ( 'cities' )
1020+ . findNearest ( {
1021+ field : 'embedding' ,
1022+ vectorValue : [ 1.5 , 2.345 ] ,
1023+ distanceMeasure : 'COSINE' ,
1024+ distanceField : 'computedDistance' ,
1025+ limit : 10 ,
1026+ } ) ;
10341027void pipelineFindNearest ;
10351028
10361029const pipelineSampleAndUnnest = pipelineDb
@@ -1113,7 +1106,11 @@ const _cStr: Expression = constant('hello');
11131106const _cBool : BooleanExpression = constant ( true ) ;
11141107const _cNull : Expression = constant ( null ) ;
11151108const _cUnknown : Expression = constant ( { nested : true } ) ;
1116- void _cNum ; void _cStr ; void _cBool ; void _cNull ; void _cUnknown ;
1109+ void _cNum ;
1110+ void _cStr ;
1111+ void _cBool ;
1112+ void _cNull ;
1113+ void _cUnknown ;
11171114
11181115// ----- Comparison: standalone overloads -----
11191116// greaterThan(Expression, Expression) | greaterThan(Expression, value)
@@ -1536,11 +1533,9 @@ const pipelineComparisonOps = xDb
15361533 )
15371534 . select (
15381535 field ( 'sku' ) ,
1539- conditional (
1540- field ( 'stock' ) . greaterThan ( 0 ) ,
1541- constant ( 'in-stock' ) ,
1542- constant ( 'out-of-stock' ) ,
1543- ) . as ( 'availability' ) ,
1536+ conditional ( field ( 'stock' ) . greaterThan ( 0 ) , constant ( 'in-stock' ) , constant ( 'out-of-stock' ) ) . as (
1537+ 'availability' ,
1538+ ) ,
15441539 isType ( field ( 'value' ) , 'string' ) . as ( 'isString' ) ,
15451540 logicalMaximum ( field ( 'bidA' ) , field ( 'bidB' ) ) . as ( 'topBid' ) ,
15461541 logicalMinimum ( field ( 'askA' ) , field ( 'askB' ) ) . as ( 'bottomAsk' ) ,
@@ -1595,10 +1590,7 @@ const pipelineStringOps = xDb
15951590 stringContains ( field ( 'bio' ) , 'developer' ) ,
15961591 like ( 'role' , 'eng%' ) ,
15971592 regexContains ( field ( 'phone' ) , '^\\+1' ) ,
1598- xor (
1599- field ( 'isPublic' ) . equal ( true ) ,
1600- field ( 'isVerified' ) . equal ( true ) ,
1601- ) ,
1593+ xor ( field ( 'isPublic' ) . equal ( true ) , field ( 'isVerified' ) . equal ( true ) ) ,
16021594 ) ,
16031595 )
16041596 . addFields (
@@ -1722,10 +1714,7 @@ const pipelineAllAggregates = xDb
17221714 arrayAggDistinct ( field ( 'category' ) ) . as ( 'distinctCategories' ) ,
17231715 arrayAggDistinct ( 'category' ) . as ( 'distinctCategories2' ) ,
17241716 ] ,
1725- groups : [
1726- field ( 'country' ) . as ( 'country' ) ,
1727- toLower ( field ( 'state' ) ) . as ( 'normalizedState' ) ,
1728- ] ,
1717+ groups : [ field ( 'country' ) . as ( 'country' ) , toLower ( field ( 'state' ) ) . as ( 'normalizedState' ) ] ,
17291718 } ) ;
17301719void pipelineAllAggregates ;
17311720
0 commit comments