Skip to content

Add Query.get() and MutableData-based transactions to Realtime Database #814

Open
pmodernme wants to merge 13 commits intoGitLiveApp:masterfrom
pmodernme:master
Open

Add Query.get() and MutableData-based transactions to Realtime Database #814
pmodernme wants to merge 13 commits intoGitLiveApp:masterfrom
pmodernme:master

Conversation

@pmodernme
Copy link
Copy Markdown

Summary

This PR adds two new features to the Realtime Database module.

Query.get()

Previous implementations used Query.valueEvents.first() to fetch a
value, but that returns either local or remote data depending on
whether persistence is enabled. get() always fetches from the server
and falls back to the locally-cached value (or null) if offline,
giving consistent behavior regardless of persistence settings.
Implemented on Android, Apple, and JS.

runTransaction(MutableData)

A new DatabaseReference.runTransaction overload that mirrors the
Firebase SDK's MutableData-based transaction API. Unlike the existing
serializer-based overload — which always commits — this variant lets
callers explicitly abort a transaction by returning Transaction.abort()
from the handler. Returns the committed DataSnapshot, or null if
aborted.

New public types:

  • MutableData — a multiplatform wrapper around the platform
    MutableData type, with key, value, child(), hasChildren,
    and children. Inline value<T>() / setValue<T>() extension
    functions handle serialization.
  • Transaction / Transaction.Result — DSL for returning success
    or abort from the transaction handler.

Bug fix

NSNull values in iOS DataSnapshot.value now correctly return
null instead of the NSNull sentinel object.

API surface

Public API binary-compatibility files updated for Android and JVM.

Test plan

  • Run the existing firebase-database common tests
  • Verify Query.get() returns remote data on Android, iOS, JS
  • Verify runTransaction(MutableData) commits and aborts correctly
    on all platforms
  • Verify NSNullnull fix on iOS

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant