@typed-firestore/server
Version:
Elegant, typed abstractions for Firestore in server environments
15 lines (12 loc) • 310 B
text/typescript
import {
CollectionReference,
type DocumentData,
type WithFieldValue,
} from "firebase-admin/firestore";
export async function addDocument<T extends DocumentData>(
ref: CollectionReference<T>,
data: WithFieldValue<T>
): Promise<string> {
const docRef = await ref.add(data);
return docRef.id;
}