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
| Param | Type | Description |
|---|---|---|
path* | string | The path to the data in the Realtime Database. |
data* | T | The 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.