File tree Expand file tree Collapse file tree
snippets/firestore-temp/test-firestore Expand file tree Collapse file tree Original file line number Diff line number Diff line change 1+ // This snippet file was generated by processing the source file:
2+ // ./firestore-temp/test.firestore.js
3+ //
4+ // To update the snippets in this file, edit the source and then run
5+ // 'npm run snippets'.
6+
7+ // [START define_example_modular]
8+ const result = await db . pipeline ( ) . collection ( "authors" )
9+ . define (
10+ field ( "id" ) . as ( "currentAuthorId" )
11+ )
12+ // [END define_example_modular]
Original file line number Diff line number Diff line change 1+ // This snippet file was generated by processing the source file:
2+ // ./firestore-temp/test.firestore.js
3+ //
4+ // To update the snippets in this file, edit the source and then run
5+ // 'npm run snippets'.
6+
7+ // [START delete_dml_modular]
8+ const pipeline = db . pipeline ( )
9+ . collectionGroup ( "users" )
10+ . where ( field ( "address.country" ) . equal ( "USA" ) )
11+ . where ( field ( "__create_time__" ) . timestampAdd ( "day" , 10 ) . lessThan ( currentTimestamp ( ) ) )
12+ . delete ( ) ;
13+ await pipeline . execute ( ) ;
14+ // [END delete_dml_modular]
Original file line number Diff line number Diff line change 1+ // This snippet file was generated by processing the source file:
2+ // ./firestore-temp/test.firestore.js
3+ //
4+ // To update the snippets in this file, edit the source and then run
5+ // 'npm run snippets'.
6+
7+ // [START force_index_id_modular]
8+ // Force Planner to use Index ID CICAgOi36pgK
9+ await db . pipeline ( )
10+ . collectionGroup ( { collectionId : "customers" , forceIndex : "CICAgOi36pgK" } )
11+ . limit ( 100 )
12+ . execute ( ) ;
13+ // [END force_index_id_modular]
Original file line number Diff line number Diff line change 1+ // This snippet file was generated by processing the source file:
2+ // ./firestore-temp/test.firestore.js
3+ //
4+ // To update the snippets in this file, edit the source and then run
5+ // 'npm run snippets'.
6+
7+ // [START force_index_primary_modular]
8+ // Force Planner to only do a collection scan
9+ await db . pipeline ( )
10+ . collectionGroup ( { collectionId : "customers" , forceIndex : "primary" } )
11+ . limit ( 100 )
12+ . execute ( ) ;
13+ // [END force_index_primary_modular]
Original file line number Diff line number Diff line change 1+ // This snippet file was generated by processing the source file:
2+ // ./firestore-temp/test.firestore.js
3+ //
4+ // To update the snippets in this file, edit the source and then run
5+ // 'npm run snippets'.
6+
7+ // [START search_exact_match_modular]
8+ await db . pipeline ( ) . collection ( 'restaurants' )
9+ . search ( {
10+ query : documentMatches ( '"belgian waffles"' )
11+ } )
12+ . execute ( ) ;
13+ // [END search_exact_match_modular]
Original file line number Diff line number Diff line change 1+ // This snippet file was generated by processing the source file:
2+ // ./firestore-temp/test.firestore.js
3+ //
4+ // To update the snippets in this file, edit the source and then run
5+ // 'npm run snippets'.
6+
7+ // [START search_example_modular]
8+ await db . pipeline ( ) . collection ( 'restaurants' )
9+ . search ( {
10+ query : documentMatches ( 'waffles' )
11+ } )
12+ . execute ( ) ;
13+ // [END search_example_modular]
Original file line number Diff line number Diff line change 1+ // This snippet file was generated by processing the source file:
2+ // ./firestore-temp/test.firestore.js
3+ //
4+ // To update the snippets in this file, edit the source and then run
5+ // 'npm run snippets'.
6+
7+ // [START search_exclude_term_modular]
8+ await db . pipeline ( ) . collection ( 'restaurants' )
9+ . search ( {
10+ query : documentMatches ( '-waffles' )
11+ } )
12+ . execute ( ) ;
13+ // [END search_exclude_term_modular]
Original file line number Diff line number Diff line change 1+ // This snippet file was generated by processing the source file:
2+ // ./firestore-temp/test.firestore.js
3+ //
4+ // To update the snippets in this file, edit the source and then run
5+ // 'npm run snippets'.
6+
7+ // [START search_score_field_modular]
8+ await db . pipeline ( ) . collection ( 'restaurants' )
9+ . search ( {
10+ query : field ( 'menu' ) . matches ( 'waffles' ) ,
11+ addFields : [
12+ score ( ) . as ( 'score' ) ,
13+ ]
14+ } ) . execute ( ) ;
15+ // [END search_score_field_modular]
Original file line number Diff line number Diff line change 1+ // This snippet file was generated by processing the source file:
2+ // ./firestore-temp/test.firestore.js
3+ //
4+ // To update the snippets in this file, edit the source and then run
5+ // 'npm run snippets'.
6+
7+ // [START search_two_terms_modular]
8+ await db . pipeline ( ) . collection ( 'restaurants' )
9+ . search ( {
10+ query : documentMatches ( 'waffles eggs' )
11+ } )
12+ . execute ( ) ;
13+ // [END search_two_terms_modular]
Original file line number Diff line number Diff line change 1+ // This snippet file was generated by processing the source file:
2+ // ./firestore-temp/test.firestore.js
3+ //
4+ // To update the snippets in this file, edit the source and then run
5+ // 'npm run snippets'.
6+
7+ // [START to_array_expression_modular]
8+ await db . pipeline ( ) . collection ( "projects" )
9+ . define (
10+ field ( "id" ) . as ( "parentId" )
11+ )
12+ . addFields (
13+ db . pipeline ( ) . collection ( "tasks" )
14+ . where ( field ( "project_id" ) . equal ( variable ( "parentId" ) ) )
15+ . select ( field ( "title" ) )
16+ . toArrayExpression ( )
17+ . as ( "taskTitles" )
18+ )
19+ . execute ( ) ;
20+ // [END to_array_expression_modular]
You can’t perform that action at this time.
0 commit comments