Skip to content
This repository was archived by the owner on Mar 4, 2026. It is now read-only.

Commit c80e618

Browse files
feat: pipelines preview (#2450)
1 parent 04b67e0 commit c80e618

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+32955
-1214
lines changed

.eslintrc.json

Lines changed: 33 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,11 @@
33
"overrides": [
44
{
55
"files": [
6-
"dev/src/*.ts"
6+
"dev/src/**/*.ts"
7+
],
8+
"excludedFiles": [
9+
"dev/src/v1/*.ts",
10+
"dev/src/v1beta1/*.ts"
711
],
812
"parser": "@typescript-eslint/parser",
913
"rules": {
@@ -14,7 +18,14 @@
1418
"allowTypedFunctionExpressions": true
1519
}
1620
],
17-
"no-console": ["error", {"allow": ["error"]}]
21+
"no-console": ["error", {"allow": ["error"]}],
22+
"@typescript-eslint/no-unused-vars": [
23+
"warn",
24+
{
25+
// Ignore args that are underscore only
26+
"argsIgnorePattern": "^_$"
27+
}
28+
]
1829
}
1930
},
2031
{
@@ -35,8 +46,28 @@
3546
"property": "only"
3647
}
3748
],
49+
"@typescript-eslint/no-unused-vars": [
50+
"warn",
51+
{
52+
// Ignore args that are underscore only
53+
"argsIgnorePattern": "^_$"
54+
}
55+
],
3856
"@typescript-eslint/no-floating-promises": "warn"
3957
}
58+
},
59+
{
60+
"files": [
61+
"dev/src/v1/**/*.ts",
62+
"dev/src/v1beta1/**/*.ts",
63+
"dev/test/gapic_firestore_v1.ts",
64+
"dev/test/gapic_firestore_admin_v1.ts",
65+
"dev/test/gapic_firestore_admin_v1.ts"
66+
],
67+
"rules": {
68+
"@typescript-eslint/no-explicit-any": ["off"],
69+
"@typescript-eslint/no-floating-promises": ["off"]
70+
}
4071
}
4172
]
4273
}

.idea/runConfigurations/Unit_Tests.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

.readme-partials.yaml

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,59 @@ introduction: |-
88
Applications that use Google's Server SDKs should not be used in end-user environments, such as on phones or on publicly hosted websites. If you are developing a Web or Node.js application that accesses Cloud Firestore on behalf of end users, use the firebase Client SDK.
99
1010
**Note:** This Cloud Firestore Server SDK does not support Firestore databases created in [Datastore mode](https://cloud.google.com/datastore/docs/firestore-or-datastore#in_datastore_mode). To access these databases, use the [Datastore SDK](https://www.npmjs.com/package/@google-cloud/datastore).
11+
12+
body: |-
13+
14+
### Using the client library with Pipelines
15+
16+
```javascript
17+
18+
const {Firestore} = require('@google-cloud/firestore');
19+
20+
// Require/import Pipelines from '@google-cloud/firestore/pipelines'
21+
const {field} = require('@google-cloud/firestore/pipelines');
22+
23+
// Create a new client
24+
const firestore = new Firestore({
25+
projectId: 'firestore-sdk-nightly',
26+
databaseId: 'enterprise'
27+
});
28+
29+
async function pipelinesQuickstart() {
30+
// Obtain a collection reference.
31+
const collection = firestore.collection('books');
32+
33+
// Enter new documents into the document.
34+
await collection.add({
35+
"title": "Whispers of the Cobalt Sea",
36+
"price": 12.99,
37+
"author": "Elara Vance",
38+
"yearPublished": 2023
39+
});
40+
await collection.add({
41+
"title": "The Antigravity Cat's Guide to Napping",
42+
"price": 24.50,
43+
"author": "Mittens the IV",
44+
"yearPublished": 2026
45+
});
46+
console.log('Entered new documents into the collection.');
47+
48+
// Define a Pipeline query that selects books published this century,
49+
// orders them by price, and computes a discounted price (20% off).
50+
const pipeline = firestore.pipeline().collection('books')
51+
.where(field('yearPublished').greaterThanOrEqual(2000))
52+
.sort(field('price').ascending())
53+
.select('title', 'author', field('price').multiply(0.8).as('discountedPrice'));
54+
55+
// Execute the pipeline
56+
const pipelineSnapshot = await pipeline.execute();
57+
console.log('Executed the Pipeline.');
58+
59+
console.log('Results:');
60+
pipelineSnapshot.results.forEach(pipelineResult=> {
61+
console.log(pipelineResult.data());
62+
});
63+
}
64+
pipelinesQuickstart();
65+
66+
```

README.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,59 @@ quickstart();
9898

9999
```
100100

101+
### Using the client library with Pipelines
102+
103+
```javascript
104+
105+
const {Firestore} = require('@google-cloud/firestore');
106+
107+
// Require/import Pipelines from '@google-cloud/firestore/pipelines'
108+
const {field} = require('@google-cloud/firestore/pipelines');
109+
110+
// Create a new client
111+
const firestore = new Firestore({
112+
projectId: 'firestore-sdk-nightly',
113+
databaseId: 'enterprise'
114+
});
115+
116+
async function pipelinesQuickstart() {
117+
// Obtain a collection reference.
118+
const collection = firestore.collection('books');
119+
120+
// Enter new documents into the document.
121+
await collection.add({
122+
"title": "Whispers of the Cobalt Sea",
123+
"price": 12.99,
124+
"author": "Elara Vance",
125+
"yearPublished": 2023
126+
});
127+
await collection.add({
128+
"title": "The Antigravity Cat's Guide to Napping",
129+
"price": 24.50,
130+
"author": "Mittens the IV",
131+
"yearPublished": 2026
132+
});
133+
console.log('Entered new documents into the collection.');
134+
135+
// Define a Pipeline query that selects books published this century,
136+
// orders them by price, and computes a discounted price (20% off).
137+
const pipeline = firestore.pipeline().collection('books')
138+
.where(field('yearPublished').greaterThanOrEqual(2000))
139+
.sort(field('price').ascending())
140+
.select('title', 'author', field('price').multiply(0.8).as('discountedPrice'));
141+
142+
// Execute the pipeline
143+
const pipelineSnapshot = await pipeline.execute();
144+
console.log('Executed the Pipeline.');
145+
146+
console.log('Results:');
147+
pipelineSnapshot.results.forEach(pipelineResult=> {
148+
console.log(pipelineResult.data());
149+
});
150+
}
151+
pipelinesQuickstart();
152+
153+
```
101154

102155

103156
## Samples
@@ -107,6 +160,7 @@ Samples are in the [`samples/`](https://github.com/googleapis/nodejs-firestore/t
107160
| Sample | Source Code | Try it |
108161
| --------------------------- | --------------------------------- | ------ |
109162
| Limit-to-last-query | [source code](https://github.com/googleapis/nodejs-firestore/blob/main/samples/limit-to-last-query.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-firestore&page=editor&open_in_editor=samples/limit-to-last-query.js,samples/README.md) |
163+
| Pipelines-quickstart | [source code](https://github.com/googleapis/nodejs-firestore/blob/main/samples/pipelines-quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-firestore&page=editor&open_in_editor=samples/pipelines-quickstart.js,samples/README.md) |
110164
| Quickstart | [source code](https://github.com/googleapis/nodejs-firestore/blob/main/samples/quickstart.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-firestore&page=editor&open_in_editor=samples/quickstart.js,samples/README.md) |
111165
| Solution-counters | [source code](https://github.com/googleapis/nodejs-firestore/blob/main/samples/solution-counters.js) | [![Open in Cloud Shell][shell_img]](https://console.cloud.google.com/cloudshell/open?git_repo=https://github.com/googleapis/nodejs-firestore&page=editor&open_in_editor=samples/solution-counters.js,samples/README.md) |
112166

0 commit comments

Comments
 (0)