Skip to content

Commit bfd3758

Browse files
KingDarBojaarmando-navarro
authored andcommitted
feat(firestore): add Firestore pipelines entry points (#3799)
Add @angular/fire/firestore/pipelines and @angular/fire/firestore/lite/pipelines, generated from firebase's pipelines entry points, plus a pipeline() declaration on Lite's Firestore that firebase's own Lite typings leave out. Fixes #3693 Refs #3755 (cherry picked from commit 80ed66b)
1 parent 2f5ef49 commit bfd3758

9 files changed

Lines changed: 694 additions & 0 deletions

File tree

‎docs/firestore.md‎

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,44 @@ Update the imports from `import { ... } from 'firebase/firestore'` to `import {
5353

5454
[Getting Started](https://firebase.google.com/docs/firestore/quickstart#web-modular-api) | [API Reference](https://firebase.google.com/docs/reference/js/firestore)
5555

56+
### Pipeline operations
57+
58+
Firestore Pipeline operations are available from dedicated entrypoints:
59+
60+
```ts
61+
import { field, execute } from '@angular/fire/firestore/pipelines';
62+
import { field as liteField, execute as liteExecute } from '@angular/fire/firestore/lite/pipelines';
63+
```
64+
65+
Choose the Lite path when using Firestore Lite. Inject `Firestore`, create a pipeline with `firestore.pipeline()`, then pass it to `execute()`:
66+
67+
```ts
68+
import { inject, Component } from '@angular/core';
69+
import { Firestore } from '@angular/fire/firestore/lite';
70+
import { execute, field, greaterThan } from '@angular/fire/firestore/lite/pipelines';
71+
72+
@Component({ ... })
73+
class BooksComponent {
74+
private firestore = inject(Firestore);
75+
76+
loadBooks() {
77+
// Method Chaining
78+
const pipeline = this.firestore.pipeline()
79+
.collection('books')
80+
.where(field('rating').greaterThan(4.5));
81+
82+
// Functional Approach
83+
const pipeline = this.firestore.pipeline()
84+
.collection('books')
85+
.where(greaterThan(field('rating'), 4.5));
86+
87+
return execute(pipeline);
88+
}
89+
}
90+
```
91+
92+
Pipelines require a Firestore Enterprise edition database. Standard edition is limited to Firestore Core operations. See Firebase's [edition comparison](https://firebase.google.com/docs/firestore/compare-editions-for-native-mode), [getting started with pipelines](https://firebase.google.com/docs/firestore/pipelines/get-started-with-pipelines?hl=en), and [performing joins with sub-pipelines](https://firebase.google.com/docs/firestore/pipelines/perform-joins-with-sub-pipelines).
93+
5694
### Reading data
5795

5896
In Cloud Firestore data is stored in `documents` and `documents` are stored in `collections`. The path to data follows `<collection_name>/<document_id>` and continues if there are subcollections. For example, `"users/ABC12345/posts/XYZ6789"` represents:

‎src/firestore/lite/pipelines/firebase.ts‎

Lines changed: 292 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"$schema": "../../../../node_modules/ng-packagr/ng-package.schema.json",
3+
"lib": {
4+
"entryFile": "public_api.ts"
5+
}
6+
}
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import type { Pipeline, PipelineSource } from 'firebase/firestore/lite/pipelines';
2+
3+
declare module '@firebase/firestore/lite' {
4+
interface Firestore {
5+
pipeline(): PipelineSource<Pipeline>;
6+
}
7+
}
8+
9+
export * from './firebase';

0 commit comments

Comments
 (0)