Skip to content

Commit

Permalink
fix: broke firestore helper types when using field values like timestamp
Browse files Browse the repository at this point in the history
  • Loading branch information
jacob-8 committed Mar 19, 2024
1 parent ca89ab0 commit ae0c630
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/lib/firestore/firestore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import {
updateDoc,
serverTimestamp,
type DocumentData,
type PartialWithFieldValue,
} from 'firebase/firestore';

import { getDb } from '../init';
Expand Down Expand Up @@ -74,7 +75,7 @@ export function add<T>(

export async function set<T>(
ref: DocPredicate<T>,
data: Partial<T>,
data: PartialWithFieldValue<T>,
opts: {
abbreviate?: boolean;
merge?: boolean; // useless in a context where `update` is called for prior existing documents
Expand All @@ -93,14 +94,14 @@ export async function set<T>(

export async function update<T>(
ref: DocPredicate<T>,
data: DocumentData,
data: PartialWithFieldValue<T>,
opts: {
abbreviate?: boolean;
} = {}
): Promise<void> {
data[opts.abbreviate ? 'ua' : 'updatedAt'] = serverTimestamp();
data[opts.abbreviate ? 'ub' : 'updatedBy'] = getUid();
return updateDoc(docRef(ref), data);
return updateDoc(docRef(ref), data as DocumentData);
}

export function deleteDocument<T>(ref: DocPredicate<T>): Promise<void> {
Expand Down

0 comments on commit ae0c630

Please sign in to comment.