DatabaseReference

A Firebase reference represents a particular location in your Database and can be used for reading or writing data to that Database location.

This class is the starting point for all Database operations. After you've initialized it with a URL, you can use it to read data, write data, and to create new DatabaseReferences.

Properties

Link copied to clipboard

The underlying Firebase Android SDK object.

Link copied to clipboard
open override val compat: DatabaseReference

The Android-SDK-shaped com.google.firebase.database.DatabaseReference this wraps.

Link copied to clipboard

The underlying Firebase JS SDK database.

The underlying Firebase JS SDK database.

Link copied to clipboard
val DatabaseReference.ios: FIRDatabaseReference
val Query.ios: FIRDatabaseQuery

The underlying Firebase iOS SDK object.

Link copied to clipboard

The underlying Firebase JS SDK object.

The underlying Firebase JS SDK object.

Link copied to clipboard
val key: String?
Link copied to clipboard
Link copied to clipboard

The data at this location and every change to it; the flow fails if the listener is cancelled.

Functions

Link copied to clipboard

Get a reference to location relative to this one

Link copied to clipboard
fun childEvents(vararg types: ChildEvent.Type = arrayOf(ADDED, CHANGED, MOVED, REMOVED)): Flow<ChildEvent>

The changes to the children of this location of the given types; the flow fails if the listener is cancelled.

Link copied to clipboard
fun endAt(value: Boolean, key: String? = null): Query
fun endAt(value: Double, key: String? = null): Query
fun endAt(value: String, key: String? = null): Query

Creates a query constrained to only return child nodes with a value less than or equal to the given value, using the given orderBy directive or priority as default.

Link copied to clipboard
open operator override fun equals(other: Any?): Boolean
Link copied to clipboard
fun equalTo(value: Boolean, key: String? = null): Query
fun equalTo(value: Double, key: String? = null): Query
fun equalTo(value: String, key: String? = null): Query

Creates a query constrained to only return child nodes with the given value.

Link copied to clipboard
suspend fun get(): DataSnapshot

Gets the server values for this query. Updates the cache and raises events if successful. If not connected, falls back to a locally-cached value or null.

Link copied to clipboard
open override fun hashCode(): Int
Link copied to clipboard
fun limitToFirst(limit: Int): Query

Creates a query with limit and anchor it to the start of the window.

Link copied to clipboard
fun limitToLast(limit: Int): Query

Creates a query with limit and anchor it to the end of the window.

Link copied to clipboard

Provides access to disconnect operations at this location

Link copied to clipboard

Creates a query in which child nodes are ordered by the values of the specified path.

Link copied to clipboard

Creates a query in which child nodes are ordered by their keys.

Link copied to clipboard

Creates a query in which nodes are ordered by their value

Link copied to clipboard

Create a reference to an auto-generated child location. The child key is generated client-side and incorporates an estimate of the server's time for sorting purposes. Locations generated on a single client will be sorted in the order that they are created, and will be sorted approximately in order across all clients.

Link copied to clipboard
suspend fun removeValue()

Set the value at this location to 'null'

Link copied to clipboard
suspend fun <T> runTransaction(strategy: KSerializer<T>, buildSettings: EncodeDecodeSettingsBuilder.() -> Unit = {}, transactionUpdate: (currentData: T) -> T): DataSnapshot

Run a transaction on the data at this location.

Link copied to clipboard
inline suspend fun <T> setValue(value: T?, encodeDefaults: Boolean)
suspend fun <T> setValue(strategy: SerializationStrategy<T>, value: T, encodeDefaults: Boolean)
inline suspend fun <T> setValue(strategy: SerializationStrategy<T>, value: T, buildSettings: EncodeSettings.Builder.() -> Unit = {})

inline suspend fun <T> setValue(value: T?, buildSettings: EncodeSettings.Builder.() -> Unit = {})

Sets the value at this location, suspending until the server has acknowledged the write.

Link copied to clipboard
fun startAt(value: Boolean, key: String? = null): Query
fun startAt(value: Double, key: String? = null): Query
fun startAt(value: String, key: String? = null): Query

Creates a query constrained to only return child nodes with a value greater than or equal to the given value, using the given orderBy directive or priority as default.

Link copied to clipboard
open override fun toString(): String
Link copied to clipboard
suspend fun updateChildren(update: Map<String, Any?>, encodeDefaults: Boolean)

inline suspend fun updateChildren(update: Map<String, Any?>, buildSettings: EncodeSettings.Builder.() -> Unit = {})

Update the specific child keys to the specified values. Passing null in a map to updateChildren() will remove the value at the specified location.