A Firebase reference represents a particular location in your FirebaseDatabase and can be used for reading or writing data to that FirebaseDatabase 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 mores instances of DatabaseReference.
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.
A transaction is a data transformation function that is continually attempted until the DatabaseReference location remains unchanged during the operation.
Details
Parameters
transaction
A function to perform the transaction and return a result
A transaction is a data transformation function that is continually attempted until the DatabaseReference location remains unchanged during the operation.
Details
Parameters
transaction
A function to perform the transaction and return a result
fireLocalEvents
Defaults to true. If set to false, events will only be fired for the final result state of the transaction, and not for any intermediate states
SetPriorityAsync
TaskSetPriorityAsync(objectpriority)
Set a priority for the data at this Database location.
Set a priority for the data at this Database 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).
Note that numerical priorities are parsed and ordered as IEEE 754 double-precision floating-point numbers. Keys are always stored as strings and are treated as numeric only when they can be parsed as a 32-bit integer.
Details
Parameters
priority
The priority to set at the specified location.
Returns
The Task{TResult} for this operation.
SetRawJsonValueAsync
TaskSetRawJsonValueAsync(stringjsonValue)
Set the data at this location to the given string json represenation.
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
update
The paths to update and their new values
Returns
The Task{TResult} for this operation.
Public static functions
GoOffline
voidGoOffline()
Manually disconnect the FirebaseDatabase client from the server and disable automatic reconnection.
Manually disconnect the FirebaseDatabase client from the server and disable automatic reconnection. Note: Invoking this method will impact all FirebaseDatabase connections.
GoOnline
voidGoOnline()
Manually reestablish a connection to the FirebaseDatabase server and enable automatic reconnection.
Manually reestablish a connection to the FirebaseDatabase server and enable automatic reconnection. Note: Invoking this method will impact all FirebaseDatabase connections.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2022-07-27 UTC."],[],[],null,["Firebase.Database.DatabaseReference\n\nA [Firebase](/docs/reference/unity/namespace/firebase#namespace_firebase) reference represents a particular location in your [FirebaseDatabase](/docs/reference/unity/class/firebase/database/firebase-database#class_firebase_1_1_database_1_1_firebase_database) and can be used for reading or writing data to that [FirebaseDatabase](/docs/reference/unity/class/firebase/database/firebase-database#class_firebase_1_1_database_1_1_firebase_database) location.\n\nSummary\n\nA [Firebase](/docs/reference/unity/namespace/firebase#namespace_firebase) reference represents a particular location in your [FirebaseDatabase](/docs/reference/unity/class/firebase/database/firebase-database#class_firebase_1_1_database_1_1_firebase_database) and can be used for reading or writing data to that [FirebaseDatabase](/docs/reference/unity/class/firebase/database/firebase-database#class_firebase_1_1_database_1_1_firebase_database) location. This class is the starting point for all [Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) operations. After you've initialized it with a URL, you can use it to read data, write data, and to create mores instances of [DatabaseReference](/docs/reference/unity/class/firebase/database/database-reference#class_firebase_1_1_database_1_1_database_reference).\n\nInheritanceInherits from: [Firebase.Database.Query](/docs/reference/unity/class/firebase/database/query)\n\nProperties \n\nDatabase \n\n```c#\nFirebaseDatabase Database\n``` \nGets the [Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) instance associated with this reference.\n\n\u003cbr /\u003e\n\nKey \n\n```c#\nstring Key\n``` \nThe last token in the location pointed to by this reference \n\nParent \n\n```c#\nDatabaseReference Parent\n``` \nA [DatabaseReference](/docs/reference/unity/class/firebase/database/database-reference#class_firebase_1_1_database_1_1_database_reference) to the parent location, or null if this instance references the root location. \n\nRoot \n\n```c#\nDatabaseReference Root\n``` \nA reference to the root location of this [Firebase](/docs/reference/unity/namespace/firebase#namespace_firebase)[Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database).\n\nPublic functions \n\nChild \n\n```c#\nDatabaseReference Child(\n string pathString\n)\n``` \nGet a reference to location relative to this one\n\n\u003cbr /\u003e\n\nEquals \n\n```c#\noverride bool Equals(\n object other\n)\n``` \nReturns true if both objects reference the same database path. \n\nGetHashCode \n\n```c#\noverride int GetHashCode()\n``` \nA hash code based on the string path of the reference. \n\nOnDisconnect \n\n```c#\nOnDisconnect OnDisconnect()\n``` \nProvides access to disconnect operations at this location\n\n\u003cbr /\u003e\n\nPush \n\n```c#\nDatabaseReference Push()\n``` \nCreate a reference to an auto-generated child location.\n\nCreate 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.\n\n\u003cbr /\u003e\n\nRemoveValueAsync \n\n```c#\nTask RemoveValueAsync()\n``` \nSet the value at this location to 'null'\n\n\u003cbr /\u003e\n\nRunTransaction \n\n```c#\nTask\u003c DataSnapshot \u003e RunTransaction(\n Func\u003c MutableData, TransactionResult \u003e transaction\n)\n``` \nRun a transaction on the data at this location.\n\nA transaction is a data transformation function that is continually attempted until the [DatabaseReference](/docs/reference/unity/class/firebase/database/database-reference#class_firebase_1_1_database_1_1_database_reference) location remains unchanged during the operation.\n\n\u003cbr /\u003e\n\nRunTransaction \n\n```c#\nTask\u003c DataSnapshot \u003e RunTransaction(\n Func\u003c MutableData, TransactionResult \u003e transaction,\n bool fireLocalEvents\n)\n``` \nRun a transaction on the data at this location.\n\nA transaction is a data transformation function that is continually attempted until the [DatabaseReference](/docs/reference/unity/class/firebase/database/database-reference#class_firebase_1_1_database_1_1_database_reference) location remains unchanged during the operation.\n\n\u003cbr /\u003e\n\nSetPriorityAsync \n\n```c#\nTask SetPriorityAsync(\n object priority\n)\n``` \nSet a priority for the data at this [Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) location.\n\nSet a priority for the data at this [Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) 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). \n\n\nYou 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. \n\n\nChildren are sorted based on this priority using the following rules:\n\n- Children with no priority come first.\n- Children with a number as their priority come next. They are sorted numerically by priority (small to large).\n- Children with a string as their priority come last. They are sorted lexicographically by priority.\n- 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).\n\nNote that numerical priorities are parsed and ordered as IEEE 754 double-precision floating-point numbers. Keys are always stored as strings and are treated as numeric only when they can be parsed as a 32-bit integer.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nSetRawJsonValueAsync \n\n```c#\nTask SetRawJsonValueAsync(\n string jsonValue\n)\n``` \nSet the data at this location to the given string json represenation.\n\n\u003cbr /\u003e\n\nSetRawJsonValueAsync \n\n```c#\nTask SetRawJsonValueAsync(\n string jsonValue,\n object priority\n)\n``` \nSet the data and priority to the given values.\n\n\u003cbr /\u003e\n\nSetValueAsync \n\n```c#\nTask SetValueAsync(\n object value\n)\n``` \nSet the data at this location to the given value.\n\nSet 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:\n\n- bool\n- string\n- long\n- double\n- IDictionary{string, object}\n- List{object} \n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nSetValueAsync \n\n```c#\nTask SetValueAsync(\n object value,\n object priority\n)\n``` \nSet the data and priority to the given values.\n\nSet the data and priority to the given values. Passing null to setValue() will delete the data at the specified location. The allowed types are:\n\n- bool\n- string\n- long\n- double\n- IDictionary{string, object}\n- List{object} \n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\nToString \n\n```c#\noverride string ToString()\n``` \nThe full location url for this reference. \n\nUpdateChildrenAsync \n\n```c#\nTask UpdateChildrenAsync(\n IDictionary\u003c string, object \u003e update\n)\n``` \nUpdate the specific child keys to the specified values.\n\nUpdate the specific child keys to the specified values. Passing null in a map to updateChildren() will Remove the value at the specified location.\n\n\u003cbr /\u003e\n\nPublic static functions \n\nGoOffline \n\n```c#\nvoid GoOffline()\n``` \nManually disconnect the [Firebase](/docs/reference/unity/namespace/firebase#namespace_firebase)[Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) client from the server and disable automatic reconnection.\n\nManually disconnect the [Firebase](/docs/reference/unity/namespace/firebase#namespace_firebase)[Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) client from the server and disable automatic reconnection. Note: Invoking this method will impact all [Firebase](/docs/reference/unity/namespace/firebase#namespace_firebase)[Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) connections. \n\nGoOnline \n\n```c#\nvoid GoOnline()\n``` \nManually reestablish a connection to the [Firebase](/docs/reference/unity/namespace/firebase#namespace_firebase)[Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) server and enable automatic reconnection.\n\nManually reestablish a connection to the [Firebase](/docs/reference/unity/namespace/firebase#namespace_firebase)[Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) server and enable automatic reconnection. Note: Invoking this method will impact all [Firebase](/docs/reference/unity/namespace/firebase#namespace_firebase)[Database](/docs/reference/unity/namespace/firebase/database#namespace_firebase_1_1_database) connections."]]