@@ -15,20 +15,20 @@ import { AngularFirestoreCollection } from '../collection/collection';
15
15
16
16
/**
17
17
* AngularFirestoreDocument service
18
- *
19
- * This class creates a reference to a Firestore Document. A reference is provided in
18
+ *
19
+ * This class creates a reference to a Firestore Document. A reference is provided in
20
20
* in the constructor. The class is generic which gives you type safety for data update
21
21
* methods and data streaming.
22
- *
22
+ *
23
23
* This class uses Symbol.observable to transform into Observable using Observable.from().
24
- *
24
+ *
25
25
* This class is rarely used directly and should be created from the AngularFirestore service.
26
- *
26
+ *
27
27
* Example:
28
- *
28
+ *
29
29
* const fakeStock = new AngularFirestoreDocument<Stock>(firebase.firestore.doc('stocks/FAKE'));
30
30
* await fakeStock.set({ name: 'FAKE', price: 0.01 });
31
- * fakeStock.valueChanges().map(snap => {
31
+ * fakeStock.valueChanges().map(snap => {
32
32
* if(snap.exists) return snap.data();
33
33
* return null;
34
34
* }).subscribe(value => console.log(value));
@@ -40,21 +40,22 @@ export class AngularFirestoreDocument<T> {
40
40
/**
41
41
* The contstuctor takes in a DocumentReference to provide wrapper methods
42
42
* for data operations, data streaming, and Symbol.observable.
43
- * @param ref
43
+ * @param ref
44
44
*/
45
45
constructor ( public ref : firebase . firestore . DocumentReference ) { }
46
46
47
47
/**
48
48
* Create or overwrite a single document.
49
49
* @param data
50
+ * @param options
50
51
*/
51
- set ( data : T ) : Promise < void > {
52
- return this . ref . set ( data ) ;
52
+ set ( data : T , options ?: firebase . firestore . SetOptions ) : Promise < void > {
53
+ return this . ref . set ( data , options ) ;
53
54
}
54
55
55
56
/**
56
57
* Update some fields of a document without overwriting the entire document.
57
- * @param data
58
+ * @param data
58
59
*/
59
60
update ( data : Partial < T > ) : Promise < void > {
60
61
return this . ref . update ( data ) ;
@@ -70,8 +71,8 @@ export class AngularFirestoreDocument<T> {
70
71
/**
71
72
* Create a reference to a sub-collection given a path and an optional query
72
73
* function.
73
- * @param path
74
- * @param queryFn
74
+ * @param path
75
+ * @param queryFn
75
76
*/
76
77
collection < T > ( path : string , queryFn ?: QueryFn ) : AngularFirestoreCollection < T > {
77
78
const collectionRef = this . ref . collection ( path ) ;
0 commit comments