react-native-firebase / database/lib/modular
database/lib/modular
ServerValue
constServerValue:object
Defined in: database/lib/modular/index.d.ts:226
Server specific values.
increment()
increment(
delta):object
Returns a placeholder value that can be used to atomically increment the current database value.
connectDatabaseEmulator()
connectDatabaseEmulator(
db,host,port):void
Defined in: database/lib/modular/index.d.ts:34
Modify this Database instance to communicate with the Firebase Database emulator. This must be called synchronously immediately following the first call to firebase.database(). Do not use with production credentials as emulator traffic is not encrypted.
Note: on android, hosts 'localhost' and '127.0.0.1' are automatically remapped to '10.0.2.2' (the "host" computer IP address for android emulators) to make the standard development experience easy. If you want to use the emulator on a real android device, you will need to specify the actual host computer IP address.
enableLogging()
enableLogging(
enabled,persistent?):any
Defined in: database/lib/modular/index.d.ts:243
Logs debugging information to the console. Not implemented on native.
forceLongPolling()
forceLongPolling():
void
Defined in: database/lib/modular/index.d.ts:196
Force the use of longPolling instead of websockets. This will be ignored if websocket protocol is used in databaseURL.
forceWebSockets()
forceWebSockets():
void
Defined in: database/lib/modular/index.d.ts:201
Force the use of websockets instead of longPolling.
getDatabase()
getDatabase(
app?,url?):Module
Defined in: database/lib/modular/index.d.ts:18
Returns the instance of the Realtime Database SDK that is associated with the provided FirebaseApp. Initializes a new instance with default settings if no instance exists or if the existing instance uses a custom database URL.
getServerTime()
getServerTime(
db):Promise<number>
Defined in: database/lib/modular/index.d.ts:213
Returns the current Firebase Database server time as a JavaScript Date object.
goOffline()
goOffline(
db):Promise<void>
Defined in: database/lib/modular/index.d.ts:67
Disconnects from the server (all Database operations will be completed offline).
The client automatically maintains a persistent connection to the Database server, which
will remain active indefinitely and reconnect when disconnected. However, the goOffline() and
goOnline() methods may be used to control the client connection in cases where a persistent
connection is undesirable.
While offline, the client will no longer receive data updates from the Database. However, all Database operations performed locally will continue to immediately fire events, allowing your application to continue behaving normally. Additionally, each operation performed locally will automatically be queued and retried upon reconnection to the Database server.
To reconnect to the Database and begin receiving remote events, see goOnline().
goOnline()
goOnline(
db):Promise<void>
Defined in: database/lib/modular/index.d.ts:83
Reconnects to the server and synchronizes the offline Database state with the server state.
This method should be used after disabling the active connection with goOffline(). Once
reconnected, the client will transmit the proper data and fire the appropriate events so that
your client "catches up" automatically.
increment()
increment(
delta):object
Defined in: database/lib/modular/index.d.ts:221
Returns a placeholder value that can be used to atomically increment the current database value by the provided delta.
ref()
ref(
db,path?):Reference
Defined in: database/lib/modular/index.d.ts:104
Returns a Reference representing the location in the Database corresponding to the provided path.
If no path is provided, the Reference will point to the root of the Database.
Example
const db = getDatabase();
// Get a reference to the root of the Database
const rootRef = ref(db);
// Get a reference to the /users/ada node
const adaRef = ref(db, "users/ada");
path?
string
Optional path representing the location the returned Reference will point. If not provided, the returned Reference will point to the root of the Database.
refFromURL()
refFromURL(
db,url):Reference
Defined in: database/lib/modular/index.d.ts:115
Generates a Reference from a database URL. Note domain must be the same. Any query parameters are stripped as per the web SDK.
serverTimestamp()
serverTimestamp():
object
Defined in: database/lib/modular/index.d.ts:208
Returns a placeholder value for auto-populating the current timestamp (time since the Unix epoch, in milliseconds) as determined by the Firebase servers.
setLoggingEnabled()
setLoggingEnabled(
db,enabled):void
Defined in: database/lib/modular/index.d.ts:163
Sets the native logging level for the database module. By default, only warnings and errors are logged natively. Setting this to true will log all database events.
Ensure logging is disabled for production apps, as excessive logging can cause performance issues.
Example
const db = getDatabase();
// Set debug logging if developing
if (__DEV__) {
setLoggingEnabled(db, true);
}
setPersistenceCacheSizeBytes()
setPersistenceCacheSizeBytes(
db,bytes):void
Defined in: database/lib/modular/index.d.ts:191
By default, Firebase Database will use up to 10MB of disk space to cache data. If the cache grows beyond this size, Firebase Database will start removing data that hasn't been recently used. If you find that your application caches too little or too much data, call this method to change the cache size. This method must be called before creating your first Database reference and only needs to be called once per application.
Note that the specified cache size is only an approximation and the size on disk may temporarily exceed it at times. Cache sizes smaller than 1 MB or greater than 100 MB are not supported.
Example
const db = getDatabase();
setPersistenceEnabled(db, true);
setPersistenceCacheSizeBytes(db, 2000000); // 2MB
async function bootstrap() {
// Bootstrapping application
const snapshot = await ref(db, 'settings').once("value");
}
setPersistenceEnabled()
setPersistenceEnabled(
db,enabled):void
Defined in: database/lib/modular/index.d.ts:139
Sets whether persistence is enabled for all database calls for the current app instance.
Ensure this is called before any database calls are performed, otherwise persistence will only come into effect when the app is next started.
Example
const db = getDatabase();
setPersistenceEnabled(db, true);
async function bootstrap() {
// Bootstrapping application
const snapshot = await ref(db, "settings").once("value");
}
child
Re-exports child
DatabaseReference
Re-exports DatabaseReference
DataSnapshot
Re-exports DataSnapshot
endAt
Re-exports endAt
endBefore
Re-exports endBefore
equalTo
Re-exports equalTo
get
Re-exports get
keepSynced
Re-exports keepSynced
limitToFirst
Re-exports limitToFirst
limitToLast
Re-exports limitToLast
ListenOptions
Re-exports ListenOptions
off
Re-exports off
onChildAdded
Re-exports onChildAdded
onChildChanged
Re-exports onChildChanged
onChildMoved
Re-exports onChildMoved
onChildRemoved
Re-exports onChildRemoved
onDisconnect
Re-exports onDisconnect
OnDisconnect
Re-exports OnDisconnect
onValue
Re-exports onValue
orderByChild
Re-exports orderByChild
orderByKey
Re-exports orderByKey
orderByPriority
Re-exports orderByPriority
orderByValue
Re-exports orderByValue
push
Re-exports push
query
Re-exports query
Query
Re-exports Query
QueryConstraint
Re-exports QueryConstraint
QueryConstraintType
Re-exports QueryConstraintType
remove
Re-exports remove
runTransaction
Re-exports runTransaction
set
Re-exports set
setPriority
Re-exports setPriority
setWithPriority
Re-exports setWithPriority
startAfter
Re-exports startAfter
startAt
Re-exports startAt
ThenableReference
Re-exports ThenableReference
TransactionOptions
Re-exports TransactionOptions
TransactionResult
Re-exports TransactionResult
Unsubscribe
Re-exports Unsubscribe
update
Re-exports update
