You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* docs(db): updating the querying docs for the new API (angular#1170)
* docs(db): updating the querying docs for the new API
* docs(db): cleanup some of the formatting
* docs(db): kill unneeded quote character
* docs(db): adding a clear filter + show all results first
* docs(db): allow null in the filterBy example
* docs(readme): Callout 5.0 docs
* docs(): Update Auth-with-Ionic3-Augular4.md (angular#1171)
Fix promise-polyfill instruction and make tutorial less verbose
* Rearranging the docs a bit
* Fixes
* Moved Ionic CLI
* AngularFireDatabase/store headers
* Rearrange docs and lists
* Split querying collections into its own doc
* Databases as h4 and getting started with auth
* Right auth link
* Add a choose a database header
* Reformatting that a bit more
* Rarranged those, change header numbers
* Fixing syntax and app-root issues
* Cleaner
* Drop the 5.0@next note and 2 from more AF2 refs
* Removing the meta section from RTDB
* Querying example and doc titles
* Revamp firestore dynamic querying
* Adding an offline data doc
* Small language / typos
* Type
Firebase offers two cloud-based, client-accessible database solutions that support realtime data syncing. [Learn about the differences between them in the Firebase Documentation](https://firebase.google.com/docs/firestore/rtdb-vs-firestore).
65
+
66
+
#### Cloud Firestore
67
+
68
+
> `AngularFirestore` allows you to work with Cloud Firestore, the new flagship database for mobile app development. It improves on the successes of Realtime Database with a new, more intuitive data model. Cloud Firestore also features richer, faster queries and scales better than Realtime Database.
-[Retrieving data as objects](docs/2-retrieving-data-as-objects.md)
70
-
-[Retrieving data as lists](docs/3-retrieving-data-as-lists.md)
71
-
-[Querying lists](docs/4-querying-lists.md)
77
+
> `AngularFireDatabase` allows you to work with the Realtime Database, Firebase's original database. It's an efficient, low-latency solution for mobile apps that require synced states across clients in realtime.
78
+
79
+
-[Objects](docs/rtdb/objects.md)
80
+
-[Lists](docs/rtdb/lists.md)
81
+
-[Querying lists](docs/rtdb/querying-lists.md)
82
+
83
+
### Authenticate users
84
+
85
+
-[Getting started with Firebase Authentication](docs/auth/getting-started.md)
72
86
73
87
### Deploy to Firebase Hosting
74
-
-[Deploying AngularFire to Firebase Hosting](docs/7-deploying-angularfire-to-firebase.md)
88
+
89
+
-[Deploying AngularFire to Firebase Hosting](docs/deploying-angularfire-to-firebase.md)
75
90
76
91
### Ionic
77
-
-[Using AngularFire with Ionic 2](docs/Auth-with-Ionic2.md)
78
-
-[Using AngularFire with Ionic 3 and Angular 4](docs/Auth-with-Ionic3-Angular4.md)
92
+
93
+
-[Installation and Setup with Ionic CLI](docs/ionic/cli.md)
94
+
-[Using AngularFire with Ionic 2](docs/ionic/v2.md)
95
+
-[Using AngularFire with Ionic 3](docs/ionic/v3.md)
Copy file name to clipboardExpand all lines: docs/firestore/collections.md
+17-85
Original file line number
Diff line number
Diff line change
@@ -1,33 +1,33 @@
1
-
# Using Collections with AngularFirestore
1
+
# 3. Collections in AngularFirestore
2
2
3
-
## Understanding Collections
4
-
Every Firestore application starts with a collection. Firestore is structured in a `Collection > Document > Collection > Document` manner. This provides you with a flexible data structure. When you query a collection you only pull back the documents and not their collections. This is different from the Firebase Realtime Database where a query at a top-level location pulls back the entire tree. No more worrying about pulling back all the way down the tree 😎.
3
+
> Cloud Firestore is a NoSQL, document-oriented database. Unlike a SQL database, there are no tables or rows. Instead, you store data in *documents*, which are organized into *collections*.
4
+
Each *document* contains a set of key-value pairs. Cloud Firestore is optimized for storing large collections of small documents.
5
5
6
-
## Using an AngularFirestoreCollection
6
+
## Using `AngularFirestoreCollection`
7
7
8
-
The `AngularFirestoreCollection` service is a wrapper around the native Firestore SDK's `CollectionReference` and `Query` types. It is a generic service that provides you with a strongly typed set of methods for manipulating and streaming data. This service is designed for use as an `@Injectable()`.
8
+
The `AngularFirestoreCollection` service is a wrapper around the native Firestore SDK's [`CollectionReference`](https://firebase.google.com/docs/reference/js/firebase.firestore.CollectionReference) and [`Query`](https://firebase.google.com/docs/reference/js/firebase.firestore.Query) types. It is a generic service that provides you with a strongly typed set of methods for manipulating and streaming data. This service is designed for use as an `@Injectable()`.
Firestore has powerful querying syntax and the `AngularFirestoreCollection` provides a thin wrapper around it. This keeps you from having to learn two query syntax systems. If you know the Firestore query API then you know it for AngularFirestore ‼
143
-
144
-
When creating an `AngularFirestoreCollection`, use the optional callback to create a queried reference.
Imagine you're querying a list of T-Shirts. Every facet of the query should be parameterized. Sometimes the user will search small sizes, prices less than $20, or by a specific brand. AngularFirestore intergrates with RxJS to make this easy.
185
-
186
-
#### Basic Sample
187
-
```ts
188
-
constructor(privateafs: AngularFirestore): {
189
-
// import { of } from 'rxjs/observable/of;
190
-
// You'll use an Observable source from a ReactiveForm control or even
191
-
// an AngularFirestoreDocument
192
-
const criteria$=of({
193
-
size: 'large',
194
-
price: 10
195
-
});
196
-
this.items=criteria$.switchMap(criteria=> {
197
-
returnthis.afs
198
-
.collection<Item>('tshirts', ref=> {
199
-
returnref
200
-
.where('size', '==', criteria.size)
201
-
.where('price', '>', criteria.price)
202
-
})
203
-
.snapshotChanges();
204
-
});
205
-
}
206
-
```
207
-
208
140
## Adding documents to a collection
209
141
210
142
To add a new document to a collection with a generated id use the `add()` method. This method uses the type provided by the generic class to validate it's type structure.
@@ -219,6 +151,6 @@ To add a new document to a collection with a generated id use the `add()` method
219
151
220
152
## Manipulating individual documents
221
153
222
-
To retrieve, update, or delete an individual document you can use the `doc()` method. This method returns an `AngularFirestoreDocument`, which provides methods for streaming, updating, and deleting.
154
+
To retrieve, update, or delete an individual document you can use the `doc()` method. This method returns an `AngularFirestoreDocument`, which provides methods for streaming, updating, and deleting. [See Using Documents with AngularFirestore for more information on how to use documents](documents.md).
223
155
224
-
See the [Documents page for complete documentation]((docs/firestore/documents.md).
156
+
### [Next Step: Querying Collections in AngularFirestore](querying-collections.md)
Copy file name to clipboardExpand all lines: docs/firestore/documents.md
+10-11
Original file line number
Diff line number
Diff line change
@@ -1,30 +1,29 @@
1
-
# Using Documents with Firestore
1
+
# 2. Documents in AngularFirestore
2
2
3
-
## Understanding Documents
3
+
> Cloud Firestore is a NoSQL, document-oriented database. Unlike a SQL database, there are no tables or rows. Instead, you store data in *documents*, which are organized into *collections*.
4
+
Each *document* contains a set of key-value pairs. Cloud Firestore is optimized for storing large collections of small documents.
4
5
5
-
A Document is apart of a Collection. Firestore follows a `Collection > Document > Collection > Document` structure. Collections nested under a Document are not retrieved with a Document. You must explicitly retrieve the Collection underneath that path. This gives you a much more flexible structure. Gone are the days of worrying about pulling back the whole tree.
6
+
## Using `AngularFirestoreDocument`
6
7
7
-
## Using an AngularFirestoreDocument
8
-
9
-
The `AngularFirestoreDocument` service is a wrapper around the native Firestore SDK's `DocumentReference` type. It is a generic service that provides you with a strongly typed set of methods for manipulating and streaming data. This service is designed for use as an `@Injectable()`.
8
+
The `AngularFirestoreDocument` service is a wrapper around the native Firestore SDK's [`DocumentReference` type](https://firebase.google.com/docs/reference/js/firebase.firestore.DocumentReference). It is a generic service that provides you with a strongly typed set of methods for manipulating and streaming data. This service is designed for use as an `@Injectable()`.
> Cloud Firestore supports offline data persistence. This feature caches a copy of the Cloud Firestore data that your app is actively using, so your app can access the data when the device is offline. You can write, read, listen to, and query the cached data. When the device comes back online, Cloud Firestore synchronizes any local changes made by your app to the data stored remotely in Cloud Firestore.
4
+
5
+
**Offline persistence is an experimental feature that is supported only by the Chrome, Safari, and Firefox web browsers.** If a user opens multiple browser tabs that point to the same Cloud Firestore database, and offline persistence is enabled, Cloud Firestore will work correctly only in the first tab.
6
+
7
+
## Enable Offline Data in AngularFirestore
8
+
9
+
To enable offline persistence in your AngularFire application, call `enablePersistence()` when you are importing `AngularFirestoreModule` into your `@NgModule`:
While offline your listeners will receive listen events when the locally cached data changes. You can use to Documents and Collections normally.
34
+
35
+
To check whether you're receiving data from the server or the cache, use the `fromCache` property on the `SnapshotMetadata` in your snapshot event. If `fromCache` is true, the data came from the cache and might be stale or incomplete. If `fromCache` is false, the data is complete and current with the latest updates on the server.
36
+
37
+
[To learn more about Offline Persistence in Firestore, check out the Firebase documentation](https://firebase.google.com/docs/firestore/enable-offline).
0 commit comments