database library
The v2 slice: ref().set() and onValue against the real Firebase
Realtime Database, over FFI, with no platform channel anywhere.
This is not a FirebaseDatabasePlatform implementation yet — it is the two
operations the transport prototype set out to prove, wired to the SDK. What
it establishes is that the whole path works end to end: the build hook links
the SDK, the C ABI reaches it, listener callbacks post from SDK worker
threads, and a Variant crosses as one external typed data buffer.
Classes
- DbChildOrder
- The order of one node's children, and of theirs.
- DbChildSnapshot
- One child event, with enough context to keep an ordered list without re-reading the node.
- DbQuery
- A query over a node: an ordering, optional bounds, and an optional limit.
- DbSnapshot
- One snapshot, decoded.
- DbTransactionResult
- What a transaction handler decided.
- OnDisconnect
- What the server should do with path if this client goes away without saying goodbye.
Enums
- DbChildEvent
- What happened to a child.
- DbOrderBy
-
What a query orders by. A bound (
startAtand the rest) is meaningless without one, and the SDK requires it to be applied first.
Properties
- hasFirebase → bool
-
Whether this build linked the Firebase C++ SDK. False for the standalone
transport benchmark, which builds without it.
no setter
Functions
-
goOffline(
) → void - Drops the connection to the backend.
-
goOnline(
) → void - Restores the connection dropped by goOffline.
-
initDatabase(
{required String appId, required String apiKey, required String projectId, String? databaseUrl, String? storageBucket}) → void - Creates the App. Idempotent.
-
keepSynced(
String path, bool keep, [DbQuery? query]) → void -
Keeps
pathin sync with no listener attached, so a later read is served from cache rather than the network. -
nowNs(
) → int - The clock the native side stamps snapshots with. Exposed so a caller can measure delivery latency against a single time base rather than guessing at the offset between two.
-
onChildEvent(
String path, [DbQuery? query]) → Stream< DbChildSnapshot> - Watches the children of a node, one event per change.
-
onQueryValue(
String path, DbQuery query) → Stream< DbSnapshot> - Watches a node through a query.
-
onValue(
String path) → Stream< DbSnapshot> -
purgeOutstandingWrites(
) → void - Drops writes that have not reached the server.
-
pushChild(
String path) → String -
A new child key under
path, generated locally. -
readSnapshot(
String path, {DbQuery? query, Duration settle = const Duration(milliseconds: 400), Duration timeout = const Duration(seconds: 15)}) → Future< DbSnapshot?> - readValue, with the snapshot's child order kept.
-
readValue(
String path, {DbQuery? query, Duration settle = const Duration(milliseconds: 400), Duration timeout = const Duration(seconds: 15)}) → Future< Object?> -
Reads
pathonce, through a listener. -
removeValue(
String path) → Future< void> -
Removes whatever is at
path. -
runDbTransaction(
String path, DbTransactionResult handler(Object? current)) → Future< Object?> -
Reads
path, letshandlerdecide the next value, and writes it — retrying if it changed underneath. -
setPriority(
String path, Object? priority) → Future< void> - Sets the priority of an existing node, leaving its value alone.
-
setString(
String path, String value) → void -
ref(path).set(value)for a string value. -
setValue(
String path, Object? value) → Future< void> -
Writes
valueatpath, replacing whatever was there. -
setValueWithPriority(
String path, Object? value, Object? priority) → Future< void> -
Writes
valueatpathwithpriority, which orders it among its siblings and is what DbQuery.orderByPriority reads. -
updateChildren(
String path, Map< String, Object?> value) → Future<void> -
Writes the named children of
valueand leaves the rest alone.
Exceptions / Errors
- DatabaseException
-
ref(path).onValue.