Skip to main content
A DatabaseReference represents a specific path in the database. It provides methods for reading, writing, and querying data at that location. Obtain a reference via LarkDatabase.ref().

Properties

child

Returns a new DatabaseReference for a child location relative to this reference.

Write Methods

set

Writes a value to this location, replacing any existing data.

update

Updates specific children at this location without overwriting the entire node. Supports multi-path updates with nested path keys.

remove

Deletes the data at this location and all child locations.

push

Generates a new child location with a unique, chronologically-sortable key and optionally writes a value to it. Returns a reference to the new child.
If you omit the value, push() returns a reference with the generated key without writing anything. You can then use set() on the returned reference.

setWithPriority

Writes a value along with a priority for sorting.

setPriority

Sets the priority of data at this location without modifying the value.

Read Methods

once

Reads data from this location once. Does not subscribe to ongoing changes.

get

Reads the data at this location once. Equivalent to once('value').

Subscription Methods

on

Subscribes to data changes at this location. The callback fires immediately with the current value and again whenever the data changes. Returns an unsubscribe function. Event types:

Query Methods

All query methods return a new DatabaseReference with query constraints attached. They do not modify the original reference.

orderByChild

Orders results by the value of a specified child key.

orderByKey

Orders results by their key.

orderByValue

Orders results by their value. Useful when children are primitives.

orderByPriority

Orders results by their priority.

limitToFirst

Limits the result set to the first N items (based on the current ordering).

limitToLast

Limits the result set to the last N items (based on the current ordering).

startAt

Returns items starting at the specified value (inclusive).

startAfter

Returns items starting strictly after the specified value (exclusive).

endAt

Returns items ending at the specified value (inclusive).

endBefore

Returns items ending strictly before the specified value (exclusive).

equalTo

Returns only items matching the specified value exactly.

Other Methods

onDisconnect

Returns an OnDisconnect object that lets you register write operations to be performed on the server if the client disconnects.

transaction

Atomically reads and modifies data at this location. The updateFn receives the current value and returns the desired new value. If another client writes concurrently, the function is retried with the updated value.