@@ -28,20 +28,20 @@ map each to the appropriate type, as shown below.
28
28
29
29
``` ts
30
30
// db-refs.ts
31
- import { CollectionReference } from " firebase/firestore" ;
31
+ import { collection , type CollectionReference } from " firebase/firestore" ;
32
32
import { db } from " ./firestore" ;
33
33
import { User , WishlistItem , Book } from " ./types" ;
34
34
35
35
export const refs = {
36
36
/** For top-level collections it's easy */
37
- users: db . collection (" users" ) as CollectionReference <User >,
38
- books: db . collection (" books" ) as CollectionReference <Book >,
37
+ users: collection (db , " users" ) as CollectionReference <User >,
38
+ books: collection (db , " books" ) as CollectionReference <Book >,
39
39
/** For sub-collections you could use a function that returns the reference. */
40
40
userWishlist : (userId : string ) =>
41
- db
42
- . collection ( " users " )
43
- . doc ( userId )
44
- . collection ( " wishlist " ) as CollectionReference <WishlistItem >,
41
+ collection (
42
+ db ,
43
+ ` users/${ userId }/wishlist `
44
+ ) as CollectionReference <WishlistItem >,
45
45
46
46
/** This object never needs to change */
47
47
} as const ;
@@ -156,7 +156,7 @@ export type FsMutableDocument<T> = {
156
156
data: T ;
157
157
ref: DocumentReference <T >;
158
158
update: (data : UpdateData <T >) => Promise <void >;
159
- updatePartial: (data : Partial <T >) => Promise <void >;
159
+ updatePartial: (data : PartialWithFieldValue <T >) => Promise <void >;
160
160
delete: () => Promise <void >;
161
161
};
162
162
```
0 commit comments