Skip to content

Commit

Permalink
hotfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Moe03 committed Jun 9, 2024
1 parent 3ba1299 commit 40fe872
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "firebase-admin-rest",
"version": "0.2.3",
"version": "0.2.4",
"main": "dist/index.js",
"types": "dist/index.d.ts",
"description": "Tiny Typesafe Firebase Admin REST API wrapper that works on Vercel Edge functions, Bun, Cloudflare workers, Deno or any JS runtime.",
Expand Down
5 changes: 3 additions & 2 deletions src/firestore/RestFirestoreInstance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,10 +91,11 @@ class DocOperations<T extends object> {
* @return {Promise<GetDocumentRes<T>>} A Promise that resolves to a response object containing fetched Firestore document.
* @param {Object} options - Additional options for the operation.
*/
public async delete(): Promise<void> {
await deleteDocRest(this.docPath, {
public async delete(): Promise<any> {
const response = await deleteDocRest(this.docPath, {
db: this.databaseId,
});
return response;
}
}

Expand Down
12 changes: 11 additions & 1 deletion src/tests/class.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@ async function getDoc() {
console.log(docRef.docs[0].data())
}

async function deleteDoc() {

const db = await initFirebaseRest().firestore();
const docRef = await db.collection(`users`).limit(1).get();

console.log(docRef.docs[0].data())
const res = await db.doc(`users/${docRef.docs[0].id}`).delete()
console.log(res)
}

// getDocs example
async function getDocs() {
const db = await initFirebaseRest().firestore();
Expand Down Expand Up @@ -90,4 +100,4 @@ async function collectionToJson() {
console.log(docsRef.docReads)
}

getDoc()
deleteDoc()

0 comments on commit 40fe872

Please sign in to comment.