• Retrieves a document from Firestore based on the provided document reference.

    Example

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

    const db = admin.firestore();

    async function run() {
    try {
    const db = admin.firestore();
    const path = 'Users'
    const id = 'user123'
    const user = await get<User>(db, path, id)
    console.log(`Retrieved user: ${user.name}, age: ${user.age}`)
    } catch (error) {
    console.error(`Error retrieving document: ${error}`)
    }
    }

    run();

    Type Parameters

    • T

    Parameters

    • db: Firestore
    • collectionPath: string
    • docId: string

    Returns Promise<null | T>

    The data of the document as an object of type T or null if the document does not exist.

Generated using TypeDoc