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?: Function, context?: Record<string, any>): void;
on
</>Listens for data changes at a particular location.
on(eventType?: EventType, callback?: Function, cancelCallbackOrContext?: Record<string, any>, context?: Record<string, any> | null): Function;
once
</>Listens for exactly one event of the specified event type, and then stops listening.
once(eventType: EventType, successCallback?: Function): 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?: Function): ThenableReference;
setPriority
</>Sets a priority for the data at this Database location. Setting null removes any priority at this location.
setPriority(priority: string | number | null, onComplete?: Function): Promise<void>;
setWithPriority
</>Writes data the Database location. Like set()
but also specifies the priority for that data.
setWithPriority(newVal: any, newPriority: string | number | null, onComplete?: Function): Promise<void>;
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: Function, onComplete?: Function, applyLocally?: undefined | false | true): Promise<TransactionResult>;