@@ -1447,7 +1447,7 @@ describe("firestore-pipelines", () => {
14471447 ) ;
14481448
14491449 results = await execute ( db . pipeline ( ) . collection ( "books" )
1450- . where ( and ( field ( "rating" ) . equal ( 5 ) , ( field ( "published" ) . lessThan ( 1900 ) ) ) )
1450+ . where ( and ( field ( "rating" ) . equal ( 5 ) , field ( "published" ) . lessThan ( 1900 ) ) )
14511451 ) ;
14521452 // [END pipeline_where]
14531453 console . log ( results ) ;
@@ -1514,9 +1514,7 @@ describe("firestore-pipelines", () => {
15141514 // Type 1: Scalar (for use in non-aggregation stages)
15151515 // Example: Return the min store price for each book.
15161516 results = await execute ( db . pipeline ( ) . collection ( "books" )
1517- . select (
1518- field ( "current" ) . logicalMinimum ( [ "updated" ] ) . as ( "price_min" )
1519- )
1517+ . select ( field ( "current" ) . logicalMinimum ( field ( "updated" ) ) . as ( "price_min" ) )
15201518 ) ;
15211519
15221520 // Type 2: Aggregation (for use in aggregate stages)
@@ -1574,17 +1572,39 @@ describe("firestore-pipelines", () => {
15741572 console . log ( results ) ;
15751573 }
15761574
1577- function pagination ( ) {
1575+ async function pagination ( ) {
15781576 // [START pagination_not_supported_preview]
15791577 // Existing pagination via `startAt()`
1580- const q = // db.collection("cities").orderBy("population").startAt(1000000);
1578+ const q =
15811579 query ( collection ( db , "cities" ) , orderBy ( "population" ) , startAt ( 1000000 ) ) ;
15821580
15831581 // Private preview workaround using pipelines
1582+ const pageSize = 2 ;
15841583 const pipeline = db . pipeline ( )
15851584 . collection ( "cities" )
1586- . where ( field ( "population" ) . greaterThanOrEqual ( 1000000 ) )
1587- . sort ( field ( "population" ) . descending ( ) ) ;
1585+ . select ( "name" , "population" , "__name__" )
1586+ . sort ( field ( "population" ) . descending ( ) , field ( "__name__" ) . ascending ( ) ) ;
1587+
1588+ // Page 1 results
1589+ let snapshot = await execute ( pipeline . limit ( pageSize ) ) ;
1590+
1591+ // End of page marker
1592+ const lastDoc = snapshot . results [ snapshot . results . length - 1 ] ;
1593+
1594+ // Page 2 results
1595+ snapshot = await execute (
1596+ pipeline
1597+ . where (
1598+ or (
1599+ and (
1600+ field ( "population" ) . equal ( lastDoc . get ( "population" ) ) ,
1601+ field ( "__name__" ) . greaterThan ( lastDoc . ref )
1602+ ) ,
1603+ field ( "population" ) . lessThan ( lastDoc . get ( "population" ) )
1604+ )
1605+ )
1606+ . limit ( pageSize )
1607+ ) ;
15881608 // [END pagination_not_supported_preview]
15891609 console . log ( q ) ;
15901610 console . log ( pipeline ) ;
@@ -2144,7 +2164,7 @@ describe("firestore-pipelines", () => {
21442164 const result = await execute ( db . pipeline ( )
21452165 . collection ( "books" )
21462166 . select (
2147- and ( field ( "rating" ) . greaterThan ( 4 ) , ( field ( "price" ) . lessThan ( 10 ) ) )
2167+ and ( field ( "rating" ) . greaterThan ( 4 ) , field ( "price" ) . lessThan ( 10 ) )
21482168 . as ( "under10Recommendation" )
21492169 )
21502170 ) ;
@@ -2157,7 +2177,7 @@ describe("firestore-pipelines", () => {
21572177 const result = await execute ( db . pipeline ( )
21582178 . collection ( "books" )
21592179 . select (
2160- or ( field ( "genre" ) . equal ( "Fantasy" ) , ( field ( "tags" ) . arrayContains ( "adventure" ) ) )
2180+ or ( field ( "genre" ) . equal ( "Fantasy" ) , field ( "tags" ) . arrayContains ( "adventure" ) )
21612181 . as ( "matchesSearchFilters" )
21622182 )
21632183 ) ;
@@ -2170,7 +2190,7 @@ describe("firestore-pipelines", () => {
21702190 const result = await execute ( db . pipeline ( )
21712191 . collection ( "books" )
21722192 . select (
2173- xor ( field ( "tags" ) . arrayContains ( "magic" ) , ( field ( "tags" ) . arrayContains ( "nonfiction" ) ) )
2193+ xor ( field ( "tags" ) . arrayContains ( "magic" ) , field ( "tags" ) . arrayContains ( "nonfiction" ) )
21742194 . as ( "matchesSearchFilters" )
21752195 )
21762196 ) ;
@@ -2183,7 +2203,7 @@ describe("firestore-pipelines", () => {
21832203 const result = await execute ( db . pipeline ( )
21842204 . collection ( "books" )
21852205 . select (
2186- ( field ( "tags" ) . arrayContains ( "nonfiction" ) . not ( ) )
2206+ field ( "tags" ) . arrayContains ( "nonfiction" ) . not ( )
21872207 . as ( "isFiction" )
21882208 )
21892209 ) ;
@@ -2237,7 +2257,7 @@ describe("firestore-pipelines", () => {
22372257 const result = await execute ( db . pipeline ( )
22382258 . collection ( "books" )
22392259 . select (
2240- field ( "rating" ) . logicalMaximum ( [ 1 ] ) . as ( "flooredRating" )
2260+ field ( "rating" ) . logicalMaximum ( 1 ) . as ( "flooredRating" )
22412261 )
22422262 ) ;
22432263 // [END max_logical_function]
@@ -2249,7 +2269,7 @@ describe("firestore-pipelines", () => {
22492269 const result = await execute ( db . pipeline ( )
22502270 . collection ( "books" )
22512271 . select (
2252- field ( "rating" ) . logicalMinimum ( [ 5 ] ) . as ( "cappedRating" )
2272+ field ( "rating" ) . logicalMinimum ( 5 ) . as ( "cappedRating" )
22532273 )
22542274 ) ;
22552275 // [END min_logical_function]
0 commit comments