Firebase. Database. DatabaseReference
AFirebase reference represents a particular location in yourFirebaseDatabase and can be used for reading or writing data to thatFirebaseDatabase location.
Summary
AFirebase reference represents a particular location in yourFirebaseDatabase and can be used for reading or writing data to thatFirebaseDatabase location. This class is the starting point for allDatabase operations. After you've initialized it with a URL, you can use it to read data, write data, and to create mores instances ofDatabaseReference.
Inheritance
Inherits from:Firebase.Database.QueryProperties | |
|---|---|
Database | Gets theDatabase instance associated with this reference. |
Key | stringThe last token in the location pointed to by this reference |
Parent | ADatabaseReference to the parent location, or null if this instance references the root location. |
Root | |
Public functions | |
|---|---|
Child(string pathString) | Get a reference to location relative to this one |
Equals(object other) | override boolReturns true if both objects reference the same database path. |
GetHashCode() | override intA hash code based on the string path of the reference. |
OnDisconnect() | Provides access to disconnect operations at this location |
Push() | Create a reference to an auto-generated child location. |
RemoveValueAsync() | TaskSet the value at this location to 'null' |
RunTransaction(Func<MutableData,TransactionResult > transaction) | Task<DataSnapshot >Run a transaction on the data at this location. |
RunTransaction(Func<MutableData,TransactionResult > transaction, bool fireLocalEvents) | Task<DataSnapshot >Run a transaction on the data at this location. |
SetPriorityAsync(object priority) | TaskSet a priority for the data at thisDatabase location. |
SetRawJsonValueAsync(string jsonValue) | TaskSet the data at this location to the given string json represenation. |
SetRawJsonValueAsync(string jsonValue, object priority) | TaskSet the data and priority to the given values. |
SetValueAsync(object value) | TaskSet the data at this location to the given value. |
SetValueAsync(object value, object priority) | TaskSet the data and priority to the given values. |
ToString() | override stringThe full location url for this reference. |
UpdateChildrenAsync(IDictionary< string, object > update) | TaskUpdate the specific child keys to the specified values. |
Public static functions | |
|---|---|
GoOffline() | void |
GoOnline() | void |
Properties
Database
FirebaseDatabaseDatabase
Key
stringKey
The last token in the location pointed to by this reference
Parent
DatabaseReferenceParent
ADatabaseReference to the parent location, or null if this instance references the root location.
Public functions
Child
DatabaseReferenceChild(stringpathString)
Get a reference to location relative to this one
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | A newDatabaseReference to the given path |
Equals
overrideboolEquals(objectother)
Returns true if both objects reference the same database path.
GetHashCode
overrideintGetHashCode()
A hash code based on the string path of the reference.
OnDisconnect
OnDisconnectOnDisconnect()
Provides access to disconnect operations at this location
| Details | |
|---|---|
| Returns | An object for managing disconnect operations at this location |
Push
DatabaseReferencePush()
Create a reference to an auto-generated child location.
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.
| Details | |
|---|---|
| Returns | ADatabaseReference pointing to the new location |
RemoveValueAsync
TaskRemoveValueAsync()
Set the value at this location to 'null'
| Details | |
|---|---|
| Returns | The Task{TResult} for this operation. |
RunTransaction
Task<DataSnapshot>RunTransaction(Func<MutableData,TransactionResult>transaction)
Run a transaction on the data at this location.
A transaction is a data transformation function that is continually attempted until theDatabaseReference location remains unchanged during the operation.
| Details | |||
|---|---|---|---|
| Parameters |
|
RunTransaction
Task<DataSnapshot>RunTransaction(Func<MutableData,TransactionResult>transaction,boolfireLocalEvents)
Run a transaction on the data at this location.
A transaction is a data transformation function that is continually attempted until theDatabaseReference location remains unchanged during the operation.
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
|
SetPriorityAsync
TaskSetPriorityAsync(objectpriority)
Set a priority for the data at thisDatabase location.
Set a priority for the data at thisDatabase location. Priorities can be used to provide a custom ordering for the children at a location (if no priorities are specified, the children are ordered by key).
You cannot set a priority on an empty location. For this reason setValue(data, priority) should be used when setting initial data with a specific priority and setPriority should be used when updating the priority of existing data.
Children are sorted based on this priority using the following rules:
- Children with no priority come first.
- Children with a number as their priority come next. They are sorted numerically by priority (small to large).
- Children with a string as their priority come last. They are sorted lexicographically by priority.
- Whenever two children have the same priority (including no priority), they are sorted by key. Numeric keys come first (sorted numerically), followed by the remaining keys (sorted lexicographically).
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | The Task{TResult} for this operation. |
SetRawJsonValueAsync
TaskSetRawJsonValueAsync(stringjsonValue)
Set the data at this location to the given string json represenation.
| Details | |
|---|---|
| Returns | The Task{TResult} for this operation. |
SetRawJsonValueAsync
TaskSetRawJsonValueAsync(stringjsonValue,objectpriority)
Set the data and priority to the given values.
| Details | |
|---|---|
| Returns | The Task{TResult} for this operation. |
SetValueAsync
TaskSetValueAsync(objectvalue)
Set the data at this location to the given value.
Set the data at this location to the given value. Passing null to setValue() will delete the data at the specified location. The allowed types are:
- bool
- string
- long
- double
- IDictionary{string, object}
- List{object}
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | The Task{TResult} for this operation. |
SetValueAsync
TaskSetValueAsync(objectvalue,objectpriority)
Set the data and priority to the given values.
Set the data and priority to the given values. Passing null to setValue() will delete the data at the specified location. The allowed types are:
- bool
- string
- long
- double
- IDictionary{string, object}
- List{object}
| Details | |||||
|---|---|---|---|---|---|
| Parameters |
| ||||
| Returns | The Task{TResult} for this operation. |
ToString
overridestringToString()
The full location url for this reference.
UpdateChildrenAsync
TaskUpdateChildrenAsync(IDictionary<string,object>update)
Update the specific child keys to the specified values.
Update the specific child keys to the specified values. Passing null in a map to updateChildren() will Remove the value at the specified location.
| Details | |||
|---|---|---|---|
| Parameters |
| ||
| Returns | The Task{TResult} for this operation. |
Public static functions
GoOffline
voidGoOffline()
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 2022-07-27 UTC.