@angular/fire 16.0.0-canary.596e208 → 16.0.0-canary.78407bc

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (253) hide show
  1. package/README.md +200 -0
  2. package/analytics/analytics.module.d.ts +2 -2
  3. package/analytics/firebase.d.ts +4 -1
  4. package/analytics/screen-tracking.service.d.ts +3 -3
  5. package/app-check/app-check.module.d.ts +3 -3
  6. package/app-check/firebase.d.ts +2 -1
  7. package/auth/auth.module.d.ts +2 -2
  8. package/auth/firebase.d.ts +3 -1
  9. package/auth-guard/auth-guard.d.ts +2 -2
  10. package/compat/analytics/analytics.d.ts +1 -3
  11. package/compat/analytics/analytics.module.d.ts +1 -1
  12. package/compat/analytics/screen-tracking.service.d.ts +1 -1
  13. package/compat/analytics/user-tracking.service.d.ts +1 -1
  14. package/compat/auth/auth.d.ts +3 -3
  15. package/compat/auth-guard/auth-guard.d.ts +2 -2
  16. package/compat/database/database.d.ts +4 -4
  17. package/compat/database/interfaces.d.ts +2 -2
  18. package/compat/database/list/audit-trail.d.ts +1 -1
  19. package/compat/database/list/create-reference.d.ts +1 -1
  20. package/compat/database/list/data-operation.d.ts +1 -1
  21. package/compat/database/list/state-changes.d.ts +1 -1
  22. package/compat/database/object/create-reference.d.ts +1 -1
  23. package/compat/database/observable/fromRef.d.ts +1 -1
  24. package/compat/database/utils.d.ts +1 -1
  25. package/compat/firebase.app.module.d.ts +1 -1
  26. package/compat/firestore/collection/collection.d.ts +2 -2
  27. package/compat/firestore/collection-group/collection-group.d.ts +2 -2
  28. package/compat/firestore/document/document.d.ts +4 -4
  29. package/compat/firestore/firestore.d.ts +7 -7
  30. package/compat/firestore/interfaces.d.ts +2 -2
  31. package/compat/functions/functions.d.ts +3 -3
  32. package/compat/messaging/messaging.d.ts +2 -2
  33. package/compat/performance/performance.d.ts +2 -2
  34. package/compat/remote-config/remote-config.d.ts +15 -49
  35. package/compat/storage/observable/fromTask.d.ts +1 -2
  36. package/compat/storage/ref.d.ts +1 -1
  37. package/compat/storage/storage.d.ts +3 -3
  38. package/compat/storage/task.d.ts +1 -1
  39. package/database/database.module.d.ts +2 -2
  40. package/docs/analytics.md +67 -0
  41. package/docs/app-check.md +53 -0
  42. package/docs/auth.md +165 -0
  43. package/docs/compat/analytics/getting-started.md +137 -0
  44. package/docs/compat/auth/getting-started.md +162 -0
  45. package/docs/compat/auth/router-guards.md +104 -0
  46. package/docs/compat/emulators/emulators.md +134 -0
  47. package/docs/compat/firestore/collections.md +326 -0
  48. package/docs/compat/firestore/documents.md +115 -0
  49. package/docs/compat/firestore/offline-data.md +39 -0
  50. package/docs/compat/firestore/querying-collections.md +204 -0
  51. package/docs/compat/functions/functions.md +166 -0
  52. package/docs/compat/messaging/messaging.md +232 -0
  53. package/docs/compat/performance/getting-started.md +132 -0
  54. package/docs/compat/remote-config/getting-started.md +134 -0
  55. package/docs/compat/rtdb/lists.md +257 -0
  56. package/docs/compat/rtdb/objects.md +182 -0
  57. package/docs/compat/rtdb/querying-lists.md +155 -0
  58. package/docs/compat/storage/storage.md +257 -0
  59. package/docs/compat.md +70 -0
  60. package/docs/database.md +175 -0
  61. package/docs/deploy/getting-started.md +204 -0
  62. package/docs/firebase.json +16 -0
  63. package/docs/firestore.md +148 -0
  64. package/docs/functions.md +52 -0
  65. package/docs/images/analytics-illo_1x.png +0 -0
  66. package/docs/images/auth-illo_1x.png +0 -0
  67. package/docs/images/cloud-messaging-illo_1x.png +0 -0
  68. package/docs/images/database-illo_1x.png +0 -0
  69. package/docs/images/firestore-illo_1x.png +0 -0
  70. package/docs/images/functions-illo_1x.png +0 -0
  71. package/docs/images/hosting-illo_1x.png +0 -0
  72. package/docs/images/performance-illo_1x.png +0 -0
  73. package/docs/images/reCAPTCHA-logo@1x.png +0 -0
  74. package/docs/images/remote-config-illo_1x.png +0 -0
  75. package/docs/images/storage-illo_1x.png +0 -0
  76. package/docs/install-and-setup.md +114 -0
  77. package/docs/install-angular-cli-windows10.md +82 -0
  78. package/docs/install-firebase-tools.md +78 -0
  79. package/docs/messaging.md +25 -0
  80. package/docs/performance.md +57 -0
  81. package/docs/remote-config.md +53 -0
  82. package/docs/storage.md +90 -0
  83. package/docs/universal/cloud-functions.md +96 -0
  84. package/docs/universal/getting-started.md +28 -0
  85. package/docs/universal/prerendering.md +72 -0
  86. package/docs/version-4-upgrade.md +119 -0
  87. package/docs/version-5-upgrade.md +82 -0
  88. package/docs/version-6-upgrade.md +16 -0
  89. package/docs/version-7-upgrade.md +298 -0
  90. package/esm2022/analytics/analytics.mjs +1 -1
  91. package/esm2022/analytics/analytics.module.mjs +10 -10
  92. package/esm2022/analytics/firebase.mjs +5 -2
  93. package/esm2022/analytics/screen-tracking.service.mjs +11 -10
  94. package/esm2022/analytics/user-tracking.service.mjs +5 -5
  95. package/esm2022/app/app.mjs +1 -1
  96. package/esm2022/app/app.module.mjs +9 -8
  97. package/esm2022/app-check/app-check.mjs +2 -2
  98. package/esm2022/app-check/app-check.module.mjs +10 -11
  99. package/esm2022/app-check/firebase.mjs +3 -2
  100. package/esm2022/auth/auth.mjs +1 -1
  101. package/esm2022/auth/auth.module.mjs +10 -10
  102. package/esm2022/auth/firebase.mjs +4 -2
  103. package/esm2022/auth-guard/auth-guard.mjs +8 -6
  104. package/esm2022/auth-guard/auth-guard.module.mjs +7 -7
  105. package/esm2022/compat/analytics/analytics.mjs +12 -13
  106. package/esm2022/compat/analytics/analytics.module.mjs +14 -11
  107. package/esm2022/compat/analytics/screen-tracking.service.mjs +9 -9
  108. package/esm2022/compat/analytics/user-tracking.service.mjs +7 -7
  109. package/esm2022/compat/auth/auth.mjs +13 -13
  110. package/esm2022/compat/auth/auth.module.mjs +7 -7
  111. package/esm2022/compat/auth-guard/auth-guard.mjs +8 -6
  112. package/esm2022/compat/auth-guard/auth-guard.module.mjs +7 -7
  113. package/esm2022/compat/cache.mjs +2 -1
  114. package/esm2022/compat/database/database.mjs +10 -10
  115. package/esm2022/compat/database/database.module.mjs +7 -7
  116. package/esm2022/compat/database/interfaces.mjs +1 -1
  117. package/esm2022/compat/database/list/audit-trail.mjs +3 -3
  118. package/esm2022/compat/database/list/changes.mjs +5 -5
  119. package/esm2022/compat/database/list/create-reference.mjs +5 -5
  120. package/esm2022/compat/database/list/data-operation.mjs +1 -1
  121. package/esm2022/compat/database/list/snapshot-changes.mjs +1 -1
  122. package/esm2022/compat/database/list/state-changes.mjs +2 -2
  123. package/esm2022/compat/database/object/create-reference.mjs +2 -2
  124. package/esm2022/compat/database/object/snapshot-changes.mjs +1 -1
  125. package/esm2022/compat/database/observable/fromRef.mjs +3 -2
  126. package/esm2022/compat/database/utils.mjs +1 -1
  127. package/esm2022/compat/firebase.app.mjs +1 -1
  128. package/esm2022/compat/firebase.app.module.mjs +11 -9
  129. package/esm2022/compat/firestore/collection/changes.mjs +2 -2
  130. package/esm2022/compat/firestore/collection/collection.mjs +4 -4
  131. package/esm2022/compat/firestore/collection-group/collection-group.mjs +4 -4
  132. package/esm2022/compat/firestore/document/document.mjs +4 -4
  133. package/esm2022/compat/firestore/firestore.mjs +11 -11
  134. package/esm2022/compat/firestore/firestore.module.mjs +7 -7
  135. package/esm2022/compat/firestore/interfaces.mjs +1 -1
  136. package/esm2022/compat/firestore/observable/fromRef.mjs +2 -2
  137. package/esm2022/compat/functions/functions.mjs +8 -8
  138. package/esm2022/compat/functions/functions.module.mjs +7 -7
  139. package/esm2022/compat/messaging/messaging.mjs +13 -12
  140. package/esm2022/compat/messaging/messaging.module.mjs +7 -7
  141. package/esm2022/compat/performance/performance.mjs +14 -20
  142. package/esm2022/compat/performance/performance.module.mjs +8 -9
  143. package/esm2022/compat/performance/performance.service.mjs +5 -4
  144. package/esm2022/compat/proxy.mjs +6 -7
  145. package/esm2022/compat/remote-config/remote-config.mjs +10 -11
  146. package/esm2022/compat/remote-config/remote-config.module.mjs +7 -7
  147. package/esm2022/compat/storage/observable/fromTask.mjs +3 -1
  148. package/esm2022/compat/storage/pipes/storageUrl.pipe.mjs +9 -9
  149. package/esm2022/compat/storage/ref.mjs +3 -3
  150. package/esm2022/compat/storage/storage.mjs +8 -8
  151. package/esm2022/compat/storage/storage.module.mjs +7 -7
  152. package/esm2022/compat/storage/task.mjs +2 -2
  153. package/esm2022/core.mjs +1 -3
  154. package/esm2022/database/database.mjs +1 -1
  155. package/esm2022/database/database.module.mjs +10 -10
  156. package/esm2022/firestore/firebase.mjs +22 -2
  157. package/esm2022/firestore/firestore.mjs +1 -1
  158. package/esm2022/firestore/firestore.module.mjs +10 -10
  159. package/esm2022/firestore/lite/firebase.mjs +11 -2
  160. package/esm2022/firestore/lite/lite.mjs +1 -1
  161. package/esm2022/firestore/lite/lite.module.mjs +9 -9
  162. package/esm2022/firestore/lite/rxfire.mjs +4 -2
  163. package/esm2022/firestore/rxfire.mjs +4 -4
  164. package/esm2022/functions/functions.mjs +1 -1
  165. package/esm2022/functions/functions.module.mjs +10 -10
  166. package/esm2022/messaging/messaging.mjs +1 -1
  167. package/esm2022/messaging/messaging.module.mjs +9 -9
  168. package/esm2022/performance/performance.mjs +1 -1
  169. package/esm2022/performance/performance.module.mjs +12 -12
  170. package/esm2022/remote-config/is-remote-config-supported-factory.mjs +2 -2
  171. package/esm2022/remote-config/remote-config.mjs +1 -1
  172. package/esm2022/remote-config/remote-config.module.mjs +9 -9
  173. package/esm2022/storage/storage.mjs +1 -1
  174. package/esm2022/storage/storage.module.mjs +10 -10
  175. package/esm2022/zones.mjs +9 -11
  176. package/fesm2022/angular-fire-analytics.mjs +18 -14
  177. package/fesm2022/angular-fire-analytics.mjs.map +1 -1
  178. package/fesm2022/angular-fire-app-check.mjs +8 -8
  179. package/fesm2022/angular-fire-app-check.mjs.map +1 -1
  180. package/fesm2022/angular-fire-app.mjs +6 -5
  181. package/fesm2022/angular-fire-app.mjs.map +1 -1
  182. package/fesm2022/angular-fire-auth-guard.mjs +13 -11
  183. package/fesm2022/angular-fire-auth-guard.mjs.map +1 -1
  184. package/fesm2022/angular-fire-auth.mjs +8 -6
  185. package/fesm2022/angular-fire-auth.mjs.map +1 -1
  186. package/fesm2022/angular-fire-compat-analytics.mjs +29 -27
  187. package/fesm2022/angular-fire-compat-analytics.mjs.map +1 -1
  188. package/fesm2022/angular-fire-compat-auth-guard.mjs +12 -10
  189. package/fesm2022/angular-fire-compat-auth-guard.mjs.map +1 -1
  190. package/fesm2022/angular-fire-compat-auth.mjs +13 -13
  191. package/fesm2022/angular-fire-compat-auth.mjs.map +1 -1
  192. package/fesm2022/angular-fire-compat-database.mjs +129 -128
  193. package/fesm2022/angular-fire-compat-database.mjs.map +1 -1
  194. package/fesm2022/angular-fire-compat-firestore.mjs +96 -96
  195. package/fesm2022/angular-fire-compat-firestore.mjs.map +1 -1
  196. package/fesm2022/angular-fire-compat-functions.mjs +10 -10
  197. package/fesm2022/angular-fire-compat-functions.mjs.map +1 -1
  198. package/fesm2022/angular-fire-compat-messaging.mjs +13 -12
  199. package/fesm2022/angular-fire-compat-messaging.mjs.map +1 -1
  200. package/fesm2022/angular-fire-compat-performance.mjs +23 -29
  201. package/fesm2022/angular-fire-compat-performance.mjs.map +1 -1
  202. package/fesm2022/angular-fire-compat-remote-config.mjs +10 -11
  203. package/fesm2022/angular-fire-compat-remote-config.mjs.map +1 -1
  204. package/fesm2022/angular-fire-compat-storage.mjs +21 -19
  205. package/fesm2022/angular-fire-compat-storage.mjs.map +1 -1
  206. package/fesm2022/angular-fire-compat.mjs +15 -13
  207. package/fesm2022/angular-fire-compat.mjs.map +1 -1
  208. package/fesm2022/angular-fire-database.mjs +5 -5
  209. package/fesm2022/angular-fire-database.mjs.map +1 -1
  210. package/fesm2022/angular-fire-firestore-lite.mjs +19 -8
  211. package/fesm2022/angular-fire-firestore-lite.mjs.map +1 -1
  212. package/fesm2022/angular-fire-firestore.mjs +30 -10
  213. package/fesm2022/angular-fire-firestore.mjs.map +1 -1
  214. package/fesm2022/angular-fire-functions.mjs +6 -6
  215. package/fesm2022/angular-fire-functions.mjs.map +1 -1
  216. package/fesm2022/angular-fire-messaging.mjs +4 -4
  217. package/fesm2022/angular-fire-messaging.mjs.map +1 -1
  218. package/fesm2022/angular-fire-performance.mjs +7 -7
  219. package/fesm2022/angular-fire-performance.mjs.map +1 -1
  220. package/fesm2022/angular-fire-remote-config.mjs +4 -4
  221. package/fesm2022/angular-fire-remote-config.mjs.map +1 -1
  222. package/fesm2022/angular-fire-storage.mjs +4 -4
  223. package/fesm2022/angular-fire-storage.mjs.map +1 -1
  224. package/fesm2022/angular-fire.mjs +7 -11
  225. package/fesm2022/angular-fire.mjs.map +1 -1
  226. package/firestore/firebase.d.ts +21 -1
  227. package/firestore/firestore.module.d.ts +2 -2
  228. package/firestore/lite/firebase.d.ts +10 -1
  229. package/firestore/lite/lite.module.d.ts +2 -2
  230. package/firestore/lite/rxfire.d.ts +3 -1
  231. package/firestore/rxfire.d.ts +3 -3
  232. package/functions/functions.module.d.ts +2 -2
  233. package/messaging/messaging.module.d.ts +2 -2
  234. package/package.json +12 -12
  235. package/performance/performance.module.d.ts +2 -2
  236. package/remote-config/remote-config.module.d.ts +2 -2
  237. package/schematics/add/index.js +1 -1
  238. package/schematics/add/schema.json +16 -0
  239. package/schematics/builders.json +10 -0
  240. package/schematics/collection.json +15 -0
  241. package/schematics/common.js +1 -1
  242. package/schematics/deploy/actions.js +11 -11
  243. package/schematics/deploy/builder.js +2 -2
  244. package/schematics/deploy/schema.json +119 -0
  245. package/schematics/migration.json +15 -0
  246. package/schematics/setup/index.js +5 -6
  247. package/schematics/setup/prompts.js +5 -6
  248. package/schematics/setup/schema.json +16 -0
  249. package/schematics/update/index.js +1 -1
  250. package/schematics/update/v7/index.js +2 -2
  251. package/schematics/utils.js +4 -4
  252. package/storage/storage.module.d.ts +2 -2
  253. package/publish.sh +0 -1
@@ -0,0 +1,257 @@
1
+ # AngularFireStorage
2
+
3
+ > Cloud Storage is designed to help you quickly and easily store and serve user-generated content, such as photos and videos.
4
+
5
+ > **NOTE**: [AngularFire has a new tree-shakable API](../../../README.md#developer-guide), you're looking at the documentation for the compatability version of the library. [See the v7 upgrade guide for more information on this change.](../../version-7-upgrade.md).
6
+
7
+ ### Import the `NgModule`
8
+
9
+ Cloud Storage for AngularFire is contained in the `@angular/fire/storage` module namespace. Import the `AngularFireStorageModule` in your `NgModule`. This sets up the `AngularFireStorage` service for dependency injection.
10
+
11
+ ```ts
12
+ import { BrowserModule } from '@angular/platform-browser';
13
+ import { NgModule } from '@angular/core';
14
+ import { AppComponent } from './app.component';
15
+ import { AngularFireModule } from '@angular/fire/compat';
16
+ import { AngularFireStorageModule } from '@angular/fire/compat/storage';
17
+ import { environment } from '../environments/environment';
18
+
19
+ @NgModule({
20
+ imports: [
21
+ BrowserModule,
22
+ AngularFireModule.initializeApp(environment.firebase),
23
+ AngularFireStorageModule
24
+ ],
25
+ declarations: [ AppComponent ],
26
+ bootstrap: [ AppComponent ]
27
+ })
28
+ export class AppModule {}
29
+ ```
30
+
31
+ The `BUCKET` injection token can be used to customise the storage bucket.
32
+
33
+ ```ts
34
+ import {AngularFireStorageModule, BUCKET } from '@angular/fire/compat/storage';
35
+
36
+ @NgModule({
37
+ providers: [
38
+ { provide: BUCKET, useValue: 'my-bucket-name' }
39
+ ],
40
+ ...
41
+ })
42
+ export class AppModule {}
43
+ ```
44
+
45
+ ### Injecting the AngularFireStorage service
46
+
47
+ Once the `AngularFireStorageModule` is registered you can inject the `AngularFireStorage` service.
48
+
49
+ ```ts
50
+ import { Component } from '@angular/core';
51
+ import { AngularFireStorage } from '@angular/fire/compat/storage';
52
+
53
+ @Component({
54
+ selector: 'app-component',
55
+ template: ``
56
+ })
57
+ export class AppComponent {
58
+ constructor(private storage: AngularFireStorage) { }
59
+ }
60
+ ```
61
+
62
+ ### Uploading blobs
63
+
64
+ There are three options for uploading files.
65
+
66
+
67
+ | method | |
68
+ | ---------|--------------------|
69
+ | `put(data: Blob, metadata?: storage.UploadMetadata): AngularFireUploadTask` | Starts the upload of the blob to the storage reference's path. Returns an `AngularFireUploadTask` for upload monitoring. |
70
+ | `putString(data: string, format?: StringFormat, metadata?: UploadMetadata): AngularFireUploadTask` | Updates an existing item in the array. Accepts a key, database reference, or an unwrapped snapshot. |
71
+ | `upload(path: string, data: StringFormat, metadata?: UploadMetadata): AngularFireUploadTask` | Upload or update a new file to the storage reference's path. Returns an `AngularFireUploadTask` for upload monitoring. |
72
+
73
+ ### Examples
74
+
75
+ #### Uploading blobs with put
76
+
77
+ ```ts
78
+ import { Component } from '@angular/core';
79
+ import { AngularFireStorage } from '@angular/fire/compat/storage';
80
+
81
+ @Component({
82
+ selector: 'app-root',
83
+ template: `
84
+ <input type="file" (change)="uploadFile($event)">
85
+ `
86
+ })
87
+ export class AppComponent {
88
+ constructor(private storage: AngularFireStorage) { }
89
+ uploadFile(event) {
90
+ const file = event.target.files[0];
91
+ const filePath = 'name-your-file-path-here';
92
+ const ref = this.storage.ref(filePath);
93
+ const task = ref.put(file);
94
+ }
95
+ }
96
+ ```
97
+
98
+ #### Uploading blobs with putString
99
+
100
+ ```ts
101
+ import { Component } from '@angular/core';
102
+ import { AngularFireStorage } from '@angular/fire/compat/storage';
103
+
104
+ @Component({
105
+ selector: 'app-root',
106
+ template: `
107
+ <input type="file" (change)="uploadFile($event)">
108
+ `
109
+ })
110
+ export class AppComponent {
111
+ constructor(private storage: AngularFireStorage) { }
112
+ uploadFile(event) {
113
+ const file = event.target.files[0];
114
+ const filePath = 'name-your-file-path-here';
115
+ const ref = this.storage.ref(filePath);
116
+ const task = ref.putString(file);
117
+ }
118
+ }
119
+ ```
120
+
121
+ #### Uploading files with upload
122
+
123
+ ```ts
124
+ import { Component } from '@angular/core';
125
+ import { AngularFireStorage } from '@angular/fire/compat/storage';
126
+
127
+ @Component({
128
+ selector: 'app-root',
129
+ template: `
130
+ <input type="file" (change)="uploadFile($event)">
131
+ `
132
+ })
133
+ export class AppComponent {
134
+ constructor(private storage: AngularFireStorage) { }
135
+ uploadFile(event) {
136
+ const file = event.target.files[0];
137
+ const filePath = 'name-your-file-path-here';
138
+ const task = this.storage.upload(filePath, file);
139
+ }
140
+ }
141
+ ```
142
+
143
+ ### Monitoring upload percentage
144
+
145
+ An `AngularFireUploadTask` has methods for observing upload percentage as well as the final download URL.
146
+
147
+ | method | |
148
+ | ---------|--------------------|
149
+ | `snapshotChanges(): Observable<FirebaseStorage.UploadTaskSnapshot>` | Emits the raw `UploadTaskSnapshot` as the file upload progresses. |
150
+ | `percentageChanges(): Observable<number>` | Emits the upload completion percentage. |
151
+ | `getDownloadURL(): Observable<any>` | Emits the download url when available |
152
+
153
+ #### Example Usage
154
+
155
+ The method `getDownloadURL()` doesn't rely on the task anymore, hence, in order to get the url we should use the finalize method from RxJS on top of the storage ref.
156
+
157
+ ```ts
158
+ import { finalize } from 'rxjs/operators';
159
+
160
+ @Component({
161
+ selector: 'app-root',
162
+ template: `
163
+ <input type="file" (change)="uploadFile($event)" />
164
+ <div>{{ uploadPercent | async }}</div>
165
+ <a [href]="downloadURL | async">{{ downloadURL | async }}</a>
166
+ `
167
+ })
168
+ export class AppComponent {
169
+ uploadPercent: Observable<number>;
170
+ downloadURL: Observable<string>;
171
+ constructor(private storage: AngularFireStorage) {}
172
+ uploadFile(event) {
173
+ const file = event.target.files[0];
174
+ const filePath = 'name-your-file-path-here';
175
+ const fileRef = this.storage.ref(filePath);
176
+ const task = this.storage.upload(filePath, file);
177
+
178
+ // observe percentage changes
179
+ this.uploadPercent = task.percentageChanges();
180
+ // get notified when the download URL is available
181
+ task.snapshotChanges().pipe(
182
+ finalize(() => this.downloadURL = fileRef.getDownloadURL() )
183
+ )
184
+ .subscribe()
185
+ }
186
+ }
187
+ ```
188
+
189
+ ### Downloading Files
190
+
191
+ A convenient pipe exists for simple in page references.
192
+
193
+ ```ts
194
+ @Component({
195
+ selector: 'app-root',
196
+ template: `<img [src]="'users/davideast.jpg' | getDownloadURL" />`
197
+ })
198
+ export class AppComponent {}
199
+ ```
200
+
201
+ To download a file you'll need to create a reference and call the `getDownloadURL()` method on an `AngularFireStorageReference`.
202
+
203
+ ```ts
204
+ @Component({
205
+ selector: 'app-root',
206
+ template: `<img [src]="profileUrl | async" />`
207
+ })
208
+ export class AppComponent {
209
+ profileUrl: Observable<string | null>;
210
+ constructor(private storage: AngularFireStorage) {
211
+ const ref = this.storage.ref('users/davideast.jpg');
212
+ this.profileUrl = ref.getDownloadURL();
213
+ }
214
+ }
215
+ ```
216
+
217
+ ### Managing Metadata
218
+
219
+ Cloud Storage for Firebase allows you to upload and download metadata associated with files. This is useful because you can store important metadata and download it without needing to download the entire file.
220
+
221
+ ### Examples
222
+
223
+ #### Downloading metadata
224
+
225
+ ```ts
226
+ @Component({
227
+ selector: 'app-root',
228
+ template: `<pre><code>{{ meta | async }}</code></pre>`
229
+ })
230
+ export class AppComponent {
231
+ meta: Observable<any>;
232
+ constructor(private storage: AngularFireStorage) {
233
+ const ref = this.storage.ref('users/davideast.jpg');
234
+ this.meta = ref.getMetadata();
235
+ }
236
+ }
237
+ ```
238
+
239
+ #### Uploading metadata with files
240
+
241
+ ```ts
242
+ @Component({
243
+ selector: 'app-root',
244
+ template: `
245
+ <input type="file" (change)="uploadFile($event)" />
246
+ `
247
+ })
248
+ export class AppComponent {
249
+ constructor(private storage: AngularFireStorage) {}
250
+ uploadFile(event) {
251
+ const file = event.target.files[0];
252
+ const filePath = 'name-your-file-path-here';
253
+ const ref = this.storage.ref(filePath);
254
+ const task = ref.put(file, { customMetadata: { blah: 'blah' } });
255
+ }
256
+ }
257
+ ```
package/docs/compat.md ADDED
@@ -0,0 +1,70 @@
1
+ # AngularFire
2
+ The official [Angular](https://angular.io/) library for [Firebase](https://firebase.google.com/).
3
+
4
+ <strong><pre>ng add @angular/fire</pre></strong>
5
+
6
+ ## Compatibility Developer Guide
7
+
8
+ AngularFire has a new tree-shakable API, you're looking at the documentation for the compatability version of the library. [Find the new developer guide here](../README.md#developer-guide).
9
+
10
+ [See the v7 upgrade guide for more information on this change.](version-7-upgrade.md).
11
+
12
+ ### Monitor usage of your application in production
13
+
14
+ > `AngularFireAnalytics` provides a convenient method of interacting with Google Analytics in your Angular application. The provided `ScreenTrackingService` and `UserTrackingService` automatically log events when you're using the Angular Router or Firebase Authentication respectively. [Learn more about Google Analytics](https://firebase.google.com/docs/analytics).
15
+
16
+ - [Getting started with Google Analytics](compat/analytics/getting-started.md)
17
+
18
+ ### Interacting with your database(s)
19
+
20
+ 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).
21
+
22
+ #### Cloud Firestore
23
+
24
+ > `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.
25
+
26
+ - [Documents](compat/firestore/documents.md)
27
+ - [Collections](compat/firestore/collections.md)
28
+ - [Querying Collections](compat/firestore/querying-collections.md)
29
+ - [Offline data](compat/firestore/offline-data.md)
30
+
31
+ #### Realtime Database
32
+
33
+ > `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.
34
+
35
+ - [Objects](compat/rtdb/objects.md)
36
+ - [Lists](compat/rtdb/lists.md)
37
+ - [Querying lists](compat/rtdb/querying-lists.md)
38
+
39
+ ### Authenticate users
40
+
41
+ - [Getting started with Firebase Authentication](acompat/uth/getting-started.md)
42
+ - [Route users with AngularFire guards](compat/auth/router-guards.md)
43
+
44
+ ### Local Emulator Suite
45
+
46
+ - [Getting started with Firebase Emulator Suite](compat/emulators/emulators.md)
47
+
48
+ ### Upload files
49
+
50
+ - [Getting started with Cloud Storage](compat/storage/storage.md)
51
+
52
+ ### Receive push notifications
53
+
54
+ - [Getting started with Firebase Messaging](compat/messaging/messaging.md)
55
+
56
+ ### **BETA:** Change behavior and appearance of your application without deploying
57
+
58
+ > Firebase Remote Config is a cloud service that lets you change the behavior and appearance of your app without requiring users to download an app update. [Learn more about Remote Config](https://firebase.google.com/docs/remote-config).
59
+
60
+ - [Getting started with Remote Config](compat/remote-config/getting-started.md)
61
+
62
+ ### Monitor your application performance in production
63
+
64
+ > Firebase Performance Monitoring is a service that helps you to gain insight into the performance characteristics of your iOS, Android, and web apps. [Learn more about Performance Monitoring](https://firebase.google.com/docs/perf-mon).
65
+
66
+ - [Getting started with Performance Monitoring](compat/performance/getting-started.md)
67
+
68
+ ### Directly call Cloud Functions
69
+
70
+ - [Getting started with Callable Functions](compat/functions/functions.md)
@@ -0,0 +1,175 @@
1
+ <img align="right" width="30%" src="images/database-illo_1x.png">
2
+
3
+ <small>
4
+ <a href="https://github.com/angular/angularfire">AngularFire</a> &#10097; <a href="../README.md#developer-guide">Developer Guide</a> &#10097; Realtime Database
5
+ </small>
6
+
7
+ # Realtime Database
8
+
9
+ Store and sync data with our NoSQL cloud database. Data is synced across all clients in realtime, and remains available when your app goes offline.
10
+
11
+ The Firebase Realtime Database is a cloud-hosted database. Data is stored as JSON and synchronized in realtime to every connected client. When you build cross-platform apps with our iOS, Android, and JavaScript SDKs, all of your clients share one Realtime Database instance and automatically receive updates with the newest data. [Learn more about the Realtime Database](https://firebase.google.com/docs/database).
12
+
13
+ ## Dependency Injection
14
+
15
+ As a prerequisite, ensure that `AngularFire` has been added to your project via
16
+ ```bash
17
+ ng add @angular/fire
18
+ ```
19
+
20
+ Provide an RTBD instance in the application's `NgModule` (`app.module.ts`):
21
+
22
+ ```ts
23
+ import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
24
+ import { getDatabase, provideDatabase } from '@angular/fire/database';
25
+
26
+ @NgModule({
27
+ imports: [
28
+ provideFirebaseApp(() => initializeApp(environment.firebase)),
29
+ provideDatabase(() => getDatabase()),
30
+ ]
31
+ })
32
+ ```
33
+
34
+ Next inject it into your component:
35
+
36
+ ```ts
37
+ import { Component, inject } from '@angular/core';
38
+ import { Database } from '@angular/fire/database';
39
+
40
+ @Component({...})
41
+ extend class DepartmentComponent {
42
+ private database: Database = inject(Database);
43
+
44
+ constructor() {
45
+ }
46
+ }
47
+ ```
48
+
49
+ ## Firebase API
50
+
51
+ AngularFire wraps the Firebase JS SDK to ensure proper functionality in Angular, while providing the same API.
52
+
53
+ Just change your imports from `import { ... } from 'firebase/database'` to `import { ... } from '@angular/fire/database'` and follow the offical documentation.
54
+
55
+ [Getting Started](https://firebase.google.com/docs/database/web/start) | [API Reference](https://firebase.google.com/docs/reference/js/database)
56
+
57
+ ## Convenience observables
58
+
59
+ AngularFire provides observables to allow convenient use of the Realtime Database with RXJS.
60
+
61
+ ### `object`
62
+
63
+ The `object()` function creates an observable that emits object changes.
64
+
65
+ | | |
66
+ |-----------------|------------------------------------------|
67
+ | **function** | `object(ref)` |
68
+ | **params** | ref: `Reference` |
69
+ | **return** | `Observable<QueryChange>` |
70
+
71
+ ### `objectVal`
72
+
73
+ The `objectVal` function creates an observable that emits an array of object values, optionally with a mapped key.
74
+
75
+ | | |
76
+ |-----------------|-------------------------------------------------------|
77
+ | **function** | `objectVal(query, options?)` |
78
+ | **params** | query: `Reference\|Query`, options?: { keyField?: `string` } |
79
+ | **return** | `Observable<T>` |
80
+
81
+ ### `list`
82
+
83
+ The `list()` function creates an observable that emits a sorted array for each child event change. The optional `events` parameter will filter which child events populate the array.
84
+
85
+ | | |
86
+ |-----------------|-------------------------------------------------------|
87
+ | **function** | `list(ref, options?)` |
88
+ | **params** | ref: `Reference\|Query`, options?: { events?: `ListenEvent[]` } |
89
+ | **return** | `Observable<QueryChange[]>` |
90
+
91
+ ### `listVal`
92
+
93
+ The `listVal()` function creates an observable that emits an object mapped to its value, and optionally its key.
94
+
95
+ | | |
96
+ |-----------------|-------------------------------------------------------|
97
+ | **function** | `listVal(query, options?)` |
98
+ | **params** | ref: `Reference\|Query`, options?: { keyField?: `string` } |
99
+ | **return** | `Observable<T \| null>` |
100
+
101
+ ### `stateChanges`
102
+
103
+ The `stateChanges()` function creates an observable that emits each time a change occurs at the reference or query passed. This is useful for tracking the changes in your list. The optional `events` parameter will filter which child events populate the array.
104
+
105
+ | | |
106
+ |-----------------|------------------------------------------------------|
107
+ | **function** | `stateChanges(ref, options?)` |
108
+ | **params** | ref: `Reference\|Query`, options:? { events?: `ListenEvent[]` } |
109
+ | **return** | `Observable<QueryChange>` |
110
+
111
+ ### `auditTrail`
112
+
113
+ The `auditTrail()` function creates an observable that emits the entire state trail. This is useful for debugging or replaying the state of a list in your app. The optional `events` parameter will filter which child events populate the array.
114
+
115
+ | | |
116
+ |-----------------|------------------------------------------------------|
117
+ | **function** | `auditTrail(ref, options?)` |
118
+ | **params** | ref: `Reference\|Query`, options?: { events?: `ListenEvent[]` } |
119
+ | **return** | `Observable<QueryChange[]>` |
120
+
121
+ ### `fromRef`
122
+
123
+ The `fromRef()` function creates an observable that emits reference changes.
124
+
125
+ | | |
126
+ |-----------------|------------------------------------------|
127
+ | **function** | `fromRef(ref, event)` |
128
+ | **params** | ref: `Reference\|Query`, event: `ListenEvent` |
129
+ | **return** | `Observable<QueryChange>` |
130
+
131
+ ## Connecting to the emulator suite
132
+
133
+ ```ts
134
+ import { connectDatabaseEmulator, getDatabase, provideDatabase } from '@angular/fire/database';
135
+
136
+ @NgModule({
137
+ imports: [
138
+ provideDatabase(() => {
139
+ const database = getDatabase();
140
+ connectDatabaseEmulator(database, 'localhost', 9000);
141
+ return database;
142
+ }),
143
+ ]
144
+ })
145
+ ```
146
+
147
+ ## Working with multiple instances
148
+
149
+ ```ts
150
+ import { provideFirebaseApp, FirebaseApp, initializeApp } from '@angular/fire/app';
151
+ import { getDatabase, provideDatabase } from '@angular/fire/database';
152
+
153
+ const DATABASE_SHARD_URLS = [
154
+ 'https://FOO.firebaseio.com',
155
+ 'https://BAR.firebaseio.com',
156
+ 'https://BAZ.firebaseio.com',
157
+ ];
158
+
159
+ @NgModule({
160
+ imports: [
161
+ provideFirebaseApp(() => initializeApp(environment.firebase)),
162
+ provideDatabase((app: FirebaseApp) => getDatabase(app, DATABASE_SHARD_URLS[0])),
163
+ provideDatabase((app: FirebaseApp) => getDatabase(app, DATABASE_SHARD_URLS[1])),
164
+ provideDatabase((app: FirebaseApp) => getDatabase(app, DATABASE_SHARD_URLS[2])),
165
+ ]
166
+ })
167
+ ```
168
+
169
+ ```ts
170
+ import { DatabaseInstances } from '@angular/fire/database';
171
+
172
+ constructor(databases: DatabaseInstances) {
173
+ // databases => Database[]
174
+ }
175
+ ```