question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Database: Please add Push function into MutableData

See original GitHub issue

When I use RunTransaction function I would like to add child node like I could normally push. For simplicity the MutableData should also have Push that would generate it’s key in transaction

Is it possible?

Issue Analytics

  • State:open
  • Created 5 years ago
  • Comments:11 (10 by maintainers)

github_iconTop GitHub Comments

1reaction
chkuang-gcommented, May 24, 2019

@Thaina You are correct that if both client is trying to push { "newUniqueKey" : { "before" : null,"after" : newValue } }, the later one would be rejected and need to rerun the transaction again.

It is almost impossible to generate the same unique key using Push() in the second round-trip, assuming the timestamp calculated on all client is correct. If you want to 100% certain about 0 collision, you can always to check if the value at “newUniqueKey” is empty or not.

I can see your point to add Push() to MutableData. I can forward your opinion to the team. Since this API does not exists in iOS/Android SDK, we cannot simply add this to Unity SDK. https://firebase.google.com/docs/reference/android/com/google/firebase/database/MutableData

At the meantime, you can always use Push() from the captured DatabaseReference.

Hope this helps! Shawn

0reactions
Thainacommented, May 25, 2019

@chkuang-g Thank you very much

I don’t require that it must be implemented like I have state above. But the MutableData in transation should have some api that could do this same functionality I wish more easily

Read more comments on GitHub >

github_iconTop Results From Across the Web

Database: Please add Push function into MutableData #275
When I use RunTransaction function I would like to add child node like I could normally push. For simplicity the MutableData should also ......
Read more >
Firebase Realtime Database add to list in MutableData
How can I add to a list in a Firebase Realtime Database transaction using MutableData? ... DatabaseReference refDatabase = ... refDatabase.push().
Read more >
database package - JavaScript API reference - Firebase
This is the most common pattern for adding data to a collection of items.If you provide a value to push() , the value...
Read more >
Saving Data | Firebase Realtime Database - Google
Ways to Save Data ; push, Add to a list of data in the database. Every time you push a new node onto...
Read more >
Firebase Database problem
Hello, So I have a game with the mainMenu scene and Play scene. After I log in with LoginButton() the Text: usernameText is...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found