RefirebaseRefirebase

set

Write or replace data to a specific path in the Realtime Database.

Overview

The set method writes data to the specified path, replacing any existing data at that path and its child nodes.

Setting data
import { db } from 'refirebase';

const result = await db.realtime.set('users/user123', {
  name: 'Alice',
  role: 'admin'
});

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

Parameters

ParamTypeDescription
path*stringThe path to the data in the Realtime Database.
data*TThe data to be written at the specified path.

Return value

Returns

Promise<undefined | { error: unknown }>

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