• Deletes a document from the specified collection in Firestore.

    Throws

    Throws an exception with an error message if an error occurs.

    Example

    import { firestore } from 'firebase-admin'
    import * as admin from 'firebase-admin'
    import { remove } from '@skeet-framework/firestore'

    const db = admin.firestore();

    async function run() {
    try {
    const path = 'Users'
    const docId = '123456'; // Assuming this ID exists in the Users collection.
    const success = await remove(db, path, docId);
    if (success) {
    console.log(`Document with ID ${docId} deleted successfully.`);
    }
    } catch (error) {
    console.error(`Error deleting document: ${error}`);
    }
    }

    run();

    Parameters

    • db: Firestore

      The instance of the Firestore database to use.

    • collectionPath: string

      The path of the collection containing the document to be deleted.

    • docId: string

      The ID of the document to be deleted.

    Returns Promise<boolean>

    A boolean indicating the success of the delete operation.

Generated using TypeDoc