Database interface

The Firebase Database service interface. Extends theDatabase interface provided by the@firebase/database-compat package.

Signature:

exportinterfaceDatabaseextendsFirebaseDatabase

Extends: FirebaseDatabase

Methods

MethodDescription
getRules()Gets the currently applied security rules as a string. The return value consists of the rules source including comments.
getRulesJSON()Gets the currently applied security rules as a parsed JSON object. Any comments in the original source are stripped away.
setRules(source)Sets the specified rules on the Firebase Realtime Database instance. If the rules source is specified as a string or a Buffer, it may include comments.

Database.getRules()

Gets the currently applied security rules as a string. The return value consists of the rules source including comments.

Signature:

getRules():Promise<string>;

Returns:

Promise<string>

A promise fulfilled with the rules as a raw string.

Database.getRulesJSON()

Gets the currently applied security rules as a parsed JSON object. Any comments in the original source are stripped away.

Signature:

getRulesJSON():Promise<object>;

Returns:

Promise<object>

A promise fulfilled with the parsed rules object.

Database.setRules()

Sets the specified rules on the Firebase Realtime Database instance. If the rules source is specified as a string or a Buffer, it may include comments.

Signature:

setRules(source:string|Buffer|object):Promise<void>;

Parameters

ParameterTypeDescription
sourcestring | Buffer | objectSource of the rules to apply. Must not benull or empty.

Returns:

Promise<void>

Resolves when the rules are set on the Realtime Database.

Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.

Last updated 2024-04-16 UTC.