RefirebaseRefirebase

update

Update specific fields of an existing document.

Usage

Use db.firestore.update to modify parts of a document without replacing everything. It automatically updates the updated_at timestamp.

Update document fields
import { db } from 'refirebase';

const result = await db.firestore.update('users', 'user-123', {
  age: 29
});

if (result?.error) {
  console.error('Error updating document:', result.error);
}

Parameters

ParamTypeDescription
collectionName*stringThe name of the collection.
docId*stringThe ID of the document to update.
data*Partial<T>The specific fields to update.

Return value

Returns

Promise<undefined | FirestoreError>

Returns undefined on success, or an error object on failure.