Reference
A Reference represents a specific location in your Database and can be used for reading or writing data to that Database location.
You can reference the root or child location in your Database by calling firebase.database().ref()
or firebase.database().ref("child/path")
.
Properties
key
</>The last part of the Reference's path. For example, "ada" is the key for https://<DATABASE_NAME>.firebaseio.com/users/ada. The key of a root Reference is null.
key: string | null;
parent
</>The parent location of a Reference. The parent of a root Reference is null
.
parent: Reference | null;
Methods
child
</>Gets a Reference for the location at the specified relative path.
child(path: string): Reference;
endAt
</>Creates a Query with the specified ending point.
endAt(value: number | string | boolean | null, key?: undefined | string): Query;
equalTo
</>Creates a Query with the specified ending point.
equalTo(value: number | string | boolean | null, key?: undefined | string): Query;
isEqual
</>Returns whether or not the current and provided queries represent the same location, have the same query parameters.
isEqual(other: Query): boolean;
keepSynced
</>By calling keepSynced(true)
on a location, the data for that location will automatically
be downloaded and kept in sync, even when no listeners are attached for that location.
keepSynced(bool: boolean): Promise<void>;
limitToFirst
</>Generates a new Query
limited to the first specific number of children.
limitToFirst(limit: number): Query;
limitToLast
</>Generates a new Query
object limited to the last specific number of children.
limitToLast(limit: number): Query;
off
</>Detaches a callback previously attached with on()
.
off(eventType?: EventType, callback?: undefined | (a: DataSnapshot, b: string | null) => void, context?: Record<string, any>): void;
on
</>Listens for data changes at a particular location.
on(eventType?: EventType, callback?: undefined | (data: DataSnapshot, previousChildKey: undefined | string) => void, cancelCallbackOrContext?: (a: Error) => void | Record<string, any> | null, context?: Record<string, any> | null): (a: DataSnapshot, b: string | null) => void;
once
</>Listens for exactly one event of the specified event type, and then stops listening.
once(eventType: EventType, successCallback?: undefined | (a: DataSnapshot, b: string | null) => any, failureCallbackContext?: (a: Error) => void | Record<string, any> | null): Promise<DataSnapshot>;
orderByChild
</>Generates a new Query
object ordered by the specified child key.
orderByChild(path: string): Query;
push
</>Generates a new child location using a unique key and returns its Reference
.
push(value?: any, onComplete?: undefined | () => void): ThenableReference;
remove
</>Removes the data at this Database location.
set
</>Writes data to this Database location.
setPriority
</>Sets a priority for the data at this Database location. Setting null removes any priority at this location.
setWithPriority
</>Writes data the Database location. Like set()
but also specifies the priority for that data.
startAt
</>Creates a Query
with the specified starting point.
startAt(value: number | string | boolean | null, key?: undefined | string): Query;
transaction
</>Atomically modifies the data at this location.
transaction(transactionUpdate: (currentData: object) => object | undefined, onComplete?: undefined | (error: Error | null, committed: boolean, finalResult: DataSnapshot) => void, applyLocally?: undefined | false | true): Promise<TransactionResult>;