@@ -120,7 +120,7 @@ A new Pipeline object with this stage appended to the stage list.
120120firestore .pipeline ().collection (" books" )
121121 .addFields (
122122 field (" rating" ).as (" bookRating" ), // Rename 'rating' to 'bookRating'
123- add (5 , field (" quantity" )).as (" totalCost" ) // Calculate 'totalCost'
123+ add (field (" quantity" ), 5 ).as (" totalCost" ) // Calculate 'totalCost'
124124 );
125125
126126```
@@ -165,7 +165,7 @@ A new Pipeline object with this stage appended to the stage list.
165165firestore .pipeline ().collection (" books" )
166166 .addFields (
167167 field (" rating" ).as (" bookRating" ), // Rename 'rating' to 'bookRating'
168- add (5 , field (" quantity" )).as (" totalCost" ) // Calculate 'totalCost'
168+ add (field (" quantity" ), 5 ).as (" totalCost" ) // Calculate 'totalCost'
169169 );
170170
171171```
@@ -207,7 +207,7 @@ A new Pipeline object with this stage appended to the stage list.
207207// Calculate the average rating and the total number of books
208208firestore .pipeline ().collection (" books" )
209209 .aggregate (
210- field (" rating" ).avg ().as (" averageRating" ),
210+ field (" rating" ).average ().as (" averageRating" ),
211211 countAll ().as (" totalBooks" )
212212 );
213213
@@ -251,7 +251,7 @@ A new [Pipeline](./firestore_pipelines.pipeline.md#pipeline_class) object with t
251251// Calculate the average rating for each genre.
252252firestore .pipeline ().collection (" books" )
253253 .aggregate ({
254- accumulators: [avg (field (" rating" )).as (" avg_rating" )]
254+ accumulators: [average (field (" rating" )).as (" avg_rating" )],
255255 groups: [" genre" ]
256256 });
257257
@@ -297,7 +297,7 @@ A new [Pipeline](./firestore_pipelines.pipeline.md#pipeline_class) object with t
297297``` typescript
298298// Get a list of unique author names in uppercase and genre combinations.
299299firestore .pipeline ().collection (" books" )
300- .distinct (toUppercase (field (" author" )).as (" authorName" ), field (" genre" ), " publishedAt" )
300+ .distinct (toUpper (field (" author" )).as (" authorName" ), field (" genre" ), " publishedAt" )
301301 .select (" authorName" );
302302
303303```
@@ -341,7 +341,7 @@ A new [Pipeline](./firestore_pipelines.pipeline.md#pipeline_class) object with t
341341``` typescript
342342// Get a list of unique author names in uppercase and genre combinations.
343343firestore .pipeline ().collection (" books" )
344- .distinct (toUppercase (field (" author" )).as (" authorName" ), field (" genre" ), " publishedAt" )
344+ .distinct (toUpper (field (" author" )).as (" authorName" ), field (" genre" ), " publishedAt" )
345345 .select (" authorName" );
346346
347347```
@@ -594,7 +594,7 @@ A new [Pipeline](./firestore_pipelines.pipeline.md#pipeline_class) object with t
594594``` typescript
595595// Assume we don't have a built-in 'where' stage
596596firestore .pipeline ().collection (' books' )
597- .rawStage (' where' , [field (' published' ).lt (1900 )]) // Custom 'where' stage
597+ .rawStage (' where' , [field (' published' ).lessThan (1900 )]) // Custom 'where' stage
598598 .select (' title' , ' author' );
599599
600600```
@@ -971,7 +971,7 @@ db.pipeline().collection("books")
971971 .select (
972972 " firstName" ,
973973 field (" lastName" ),
974- field (" address" ).toUppercase ().as (" upperAddress" ),
974+ field (" address" ).toUpper ().as (" upperAddress" ),
975975 );
976976
977977```
@@ -1017,7 +1017,7 @@ db.pipeline().collection("books")
10171017 .select (
10181018 " firstName" ,
10191019 field (" lastName" ),
1020- field (" address" ).toUppercase ().as (" upperAddress" ),
1020+ field (" address" ).toUpper ().as (" upperAddress" ),
10211021 );
10221022
10231023```
@@ -1060,8 +1060,8 @@ A new [Pipeline](./firestore_pipelines.pipeline.md#pipeline_class) object with t
10601060// with the same rating
10611061firestore .pipeline ().collection (" books" )
10621062 .sort (
1063- Ordering . of ( field (" rating" ) ).descending (),
1064- Ordering . of ( field (" title" )) // Ascending order is the default
1063+ field (" rating" ).descending (),
1064+ field (" title" ). ascending ()
10651065 );
10661066
10671067```
@@ -1103,8 +1103,8 @@ A new [Pipeline](./firestore_pipelines.pipeline.md#pipeline_class) object with t
11031103// with the same rating
11041104firestore .pipeline ().collection (" books" )
11051105 .sort (
1106- Ordering . of ( field (" rating" ) ).descending (),
1107- Ordering . of ( field (" title" )) // Ascending order is the default
1106+ field (" rating" ).descending (),
1107+ field (" title" ). ascending ()
11081108 );
11091109
11101110```
@@ -1328,8 +1328,8 @@ A new Pipeline object with this stage appended to the stage list.
13281328firestore .pipeline ().collection (" books" )
13291329 .where (
13301330 and (
1331- gt (field (" rating" ), 4.0 ), // Filter for ratings greater than 4.0
1332- field (" genre" ).eq (" Science Fiction" ) // Equivalent to gt ("genre", "Science Fiction")
1331+ greaterThan (field (" rating" ), 4.0 ), // Filter for ratings greater than 4.0
1332+ field (" genre" ).equal (" Science Fiction" ) // Equivalent to equal ("genre", "Science Fiction")
13331333 )
13341334 );
13351335
@@ -1373,8 +1373,8 @@ A new Pipeline object with this stage appended to the stage list.
13731373firestore .pipeline ().collection (" books" )
13741374 .where (
13751375 and (
1376- gt (field (" rating" ), 4.0 ), // Filter for ratings greater than 4.0
1377- field (" genre" ).eq (" Science Fiction" ) // Equivalent to gt ("genre", "Science Fiction")
1376+ greaterThan (field (" rating" ), 4.0 ), // Filter for ratings greater than 4.0
1377+ field (" genre" ).equal (" Science Fiction" ) // Equivalent to equal ("genre", "Science Fiction")
13781378 )
13791379 );
13801380
@@ -1394,13 +1394,13 @@ const results1 = await execute(db.pipeline()
13941394// Example 2: Filter documents where 'genre' is "Science Fiction" and 'published' is after 1950
13951395const results2 = await execute (db .pipeline ()
13961396 .collection (" books" )
1397- .where (and (field (" genre" ).eq (" Science Fiction" ), field (" published" ).gt (1950 ))));
1397+ .where (and (field (" genre" ).equal (" Science Fiction" ), field (" published" ).greaterThan (1950 ))));
13981398
13991399// Example 3: Calculate the average rating of books published after 1980
14001400const results3 = await execute (db .pipeline ()
14011401 .collection (" books" )
1402- .where (field (" published" ).gt (1980 ))
1403- .aggregate (avg (field (" rating" )).as (" averageRating" )));
1402+ .where (field (" published" ).greaterThan (1980 ))
1403+ .aggregate (average (field (" rating" )).as (" averageRating" )));
14041404
14051405```
14061406
0 commit comments