Skip to content

Commit

Permalink
Add JSDoc for firestore adapter
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffplays2005 committed Aug 31, 2024
1 parent a46c2e8 commit e6d0ec6
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions server/src/data-layer/adapters/Firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ const converter = <T>() => ({
fromFirestore: (doc: any) => doc.data() as T
})

/**
* Firestore adapter for the application.
*/
const firestore = Object.assign(
() => {
return admin.firestore()
Expand All @@ -13,9 +16,21 @@ const firestore = Object.assign(
doc: <T>(path: string) => {
return admin.firestore().doc(path).withConverter<T>(converter<T>())
},
/**
* Collection adapter for Firestore.
* @param path The path to the collection.
* @returns The collection adapter.
*/
collection: <T>(path: string) => {
return admin.firestore().collection(path).withConverter<T>(converter<T>())
},
/**
* Subcollection adapter for Firestore.
* @param path The path to the main collection.
* @param docId The document ID from the main collection to retrieve.
* @param subpath The path to the subcollection.
* @returns The subcollection adapter.
*/
subcollection: <T>(path: string, docId: string, subpath: string) => {
return admin
.firestore()
Expand Down

0 comments on commit e6d0ec6

Please sign in to comment.