android - Firebase Transactions of Add, Delete on Multiple Nodes -


i have firebase structure contains users , groups in android. it's many many relationship.

firebase structure

when adding user in group node, add group in user node without using kind of transaction mechanism.

now need delete group case remove group node group property inside user node each user joined. there must transaction in scenario. far have dealt transaction code relies on same node not on different node.

i need know how implement transaction in case of adding , deletion on multiple nodes or there better way of implementing it.

firebase database transactions work on single node. if want use transaction, you'll have move work on entire database. kill scalability of app, not idea.

instead use multi-location update remove affected node 1 call database:

map updates = new hashmap(); updates.put("/users/-kr....", null); updates.put("/groups/-kr.../users/-kr...", null); ref.updatechildren(updates); 

now entire operation either succeed or fail, without requiring transaction.


Comments

Popular posts from this blog

python Tkinter Capturing keyboard events save as one single string -

android - InAppBilling registering BroadcastReceiver in AndroidManifest -

javascript - Z-index in d3.js -