This repository was archived by the owner on Mar 4, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 164
Expand file tree
/
Copy path.readme-partials.yaml
More file actions
66 lines (50 loc) · 3.22 KB
/
.readme-partials.yaml
File metadata and controls
66 lines (50 loc) · 3.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
introduction: |-
This is the Node.js Server SDK for [Google Cloud Firestore](https://firebase.google.com/docs/firestore/). Google Cloud Firestore is a NoSQL document database built for automatic scaling, high performance, and ease of application development.
This Cloud Firestore Server SDK uses Google’s Cloud Identity and Access Management for authentication and should only be used in trusted environments. Your Cloud Identity credentials allow you bypass all access restrictions and provide read and write access to all data in your Cloud Firestore project.
The Cloud Firestore Server SDKs are designed to manage the full set of data in your Cloud Firestore project and work best with reliable network connectivity. Data operations performed via these SDKs directly access the Cloud Firestore backend and all document reads and writes are optimized for high throughput.
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.
**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).
body: |-
### Using the client library with Pipelines
```javascript
const {Firestore} = require('@google-cloud/firestore');
// Require/import Pipelines from '@google-cloud/firestore/pipelines'
const {field} = require('@google-cloud/firestore/pipelines');
// Create a new client
const firestore = new Firestore({
projectId: 'firestore-sdk-nightly',
databaseId: 'enterprise'
});
async function pipelinesQuickstart() {
// Obtain a collection reference.
const collection = firestore.collection('books');
// Enter new documents into the document.
await collection.add({
"title": "Whispers of the Cobalt Sea",
"price": 12.99,
"author": "Elara Vance",
"yearPublished": 2023
});
await collection.add({
"title": "The Antigravity Cat's Guide to Napping",
"price": 24.50,
"author": "Mittens the IV",
"yearPublished": 2026
});
console.log('Entered new documents into the collection.');
// Define a Pipeline query that selects books published this century,
// orders them by price, and computes a discounted price (20% off).
const pipeline = firestore.pipeline().collection('books')
.where(field('yearPublished').greaterThanOrEqual(2000))
.sort(field('price').ascending())
.select('title', 'author', field('price').multiply(0.8).as('discountedPrice'));
// Execute the pipeline
const pipelineSnapshot = await pipeline.execute();
console.log('Executed the Pipeline.');
console.log('Results:');
pipelineSnapshot.results.forEach(pipelineResult=> {
console.log(pipelineResult.data());
});
}
pipelinesQuickstart();
```