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
val DatabaseReference.android: DatabaseReference
val Query.android: Query
val DatabaseReference.android: DatabaseReference
val Query.android: Query
Link copied to clipboard
val DatabaseReference.ios: FIRDatabaseReference
val Query.ios: FIRDatabaseQuery
Link copied to clipboard
val Query.js: Query
Link copied to clipboard
val key: String?
Link copied to clipboard
expect val valueEvents: Flow<DataSnapshot>

Functions

Link copied to clipboard

Get a reference to location relative to this one

Link copied to clipboard
expect fun childEvents(vararg types: ChildEvent.Type = arrayOf(ADDED, CHANGED, MOVED, REMOVED)): Flow<ChildEvent>
Link copied to clipboard
expect fun endAt(value: Boolean, key: String? = null): Query
expect fun endAt(value: Double, key: String? = null): Query
expect 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
expect fun equalTo(value: Boolean, key: String? = null): Query
expect fun equalTo(value: Double, key: String? = null): Query
expect 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
expect fun limitToFirst(limit: Int): Query

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

Link copied to clipboard
expect 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
expect fun orderByChild(path: String): Query

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

Link copied to clipboard
expect fun orderByKey(): Query

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

Link copied to clipboard
expect fun orderByValue(): Query

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)
inline suspend fun <T> setValue(value: T?, buildSettings: EncodeSettings.Builder.() -> Unit = {})
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 = {})
Link copied to clipboard
expect fun startAt(value: Boolean, key: String? = null): Query
expect fun startAt(value: Double, key: String? = null): Query
expect 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
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.