Skip to content

Commit 9884f9a

Browse files
committed
Use v9 in refs example
1 parent 4e2ba23 commit 9884f9a

File tree

1 file changed

+8
-8
lines changed

1 file changed

+8
-8
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -28,20 +28,20 @@ map each to the appropriate type, as shown below.
2828

2929
```ts
3030
// db-refs.ts
31-
import { CollectionReference } from "firebase/firestore";
31+
import { collection, type CollectionReference } from "firebase/firestore";
3232
import { db } from "./firestore";
3333
import { User, WishlistItem, Book } from "./types";
3434

3535
export const refs = {
3636
/** 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>,
3939
/** For sub-collections you could use a function that returns the reference. */
4040
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>,
4545

4646
/** This object never needs to change */
4747
} as const;
@@ -156,7 +156,7 @@ export type FsMutableDocument<T> = {
156156
data: T;
157157
ref: DocumentReference<T>;
158158
update: (data: UpdateData<T>) => Promise<void>;
159-
updatePartial: (data: Partial<T>) => Promise<void>;
159+
updatePartial: (data: PartialWithFieldValue<T>) => Promise<void>;
160160
delete: () => Promise<void>;
161161
};
162162
```

0 commit comments

Comments
 (0)