Skip to content

Make ServerValue.increment() public #2852

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Apr 7, 2020

Conversation

schmidt-sebastian
Copy link
Contributor

As per API proposal: go/servervalue-increment-api

@google-oss-bot
Copy link
Contributor

google-oss-bot commented Apr 2, 2020

Binary Size Report

Affected SDKs

SDKTypeBase (e062933)Head (676658b)Diff
firebasefirebase.js846328.00846327.00-1.00 (-0.00%)
firebase-database.js186834.00186833.00-1.00 (-0.00%)
@firebase/databasebrowser267885.00267892.00+7.00 (+0.00%)
module266342.00266349.00+7.00 (+0.00%)
esm2017234640.00234647.00+7.00 (+0.00%)
main268649.00268656.00+7.00 (+0.00%)
Metric Unit: byte

Test Logs

@@ -6920,6 +6920,15 @@ declare namespace firebase.database.ServerValue {
* ```
*/
var TIMESTAMP: Object;

/**
* Returns a placeholder value that can be used to atomically increment the
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

@inlined inlined Apr 2, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To the degree that we follow the same rules of course. We overflow to float instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the JS SDK itself, we don't do anything special though. Internally, we use floating point arithmetic (with its limited 2^53 precision) and once we round-trip through the server we gain land in JavaScript number land (please let me know if I am wrong here).

Firestore is a little different in that it can retain the actual value for 2^53 + 1 on the backend, whereas JavaScript cannot.

To me, it seems like the RTDB just uses JavaScript number semantics all throughout - is that correct? I can modify the comment to say that we are using floating point arithmetic throughout (similar to https://googleapis.dev/nodejs/firestore/latest/FieldValue.html#.increment), but I want to make sure that my understanding is correct.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess it just makes a difference that whole numbers would be interpreted as ints in other SDKs whereas a fractional number will cause other SDKs to see floats. OTOH that isn't different from any other field, so it doesn't really matter.

@schmidt-sebastian schmidt-sebastian assigned Feiyang1 and unassigned inlined Apr 6, 2020
@schmidt-sebastian
Copy link
Contributor Author

@Feiyang1 I need someone else to approve this too. Can you take a look?

@schmidt-sebastian schmidt-sebastian merged commit 705e9f9 into master Apr 7, 2020
@firebase firebase locked and limited conversation to collaborators May 8, 2020
@schmidt-sebastian schmidt-sebastian deleted the mrschmidt/publicincrement branch November 9, 2020 22:37
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants