RefirebaseRefirebase

update

Update specific children at a path without overwriting other data.

Overview

The update method merges the provided object with the existing data at the path. Only the specified keys are modified, while other fields remain untouched.

Updating data
import { db } from 'refirebase';

// Only updates the 'role' field, leaving 'name' untouched
const result = await db.realtime.update('users/user123', {
  role: 'superadmin'
});

if (result?.error) {
  console.error('Failed to update data:', result.error);
} else {
  console.log('Data updated successfully!');
}

Parameters

ParamTypeDescription
path*stringThe path to the data in the Realtime Database.
data*Partial<T>The subset of data fields to update.

Return value

Returns

Promise<undefined | { error: unknown }>

Returns undefined on success, or an error object if the operation fails.