Skip to content
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

Run transaction on a root node #196

Open
MrIceman opened this issue Aug 11, 2018 · 2 comments
Open

Run transaction on a root node #196

MrIceman opened this issue Aug 11, 2018 · 2 comments
Assignees

Comments

@MrIceman
Copy link

@MrIceman MrIceman commented Aug 11, 2018

Hi, I am not sure whether following problem is a design decision or an issue.

Let's assume we have this DB Structure:
{
users: {... /* a node with many users here, having their id as index / ...},
messages: {... / same as users */ ...
}

whenever I call a transaction on a root-node reference and try to access the child "users", I receive a a node with 0 children. However, I'd like to have access to all children from users.

`DatabaseReference transactionReference = FirebaseDatabase.getInstance().getReference().getRoot().runTransaction(new Transaction.Handler() {

@override
public Transaction.Result doTransaction(MutableData currentData) {
MutableData mutableUsersNode = currentData.child("users");
//mutableUsersNode.getChildrenCount() would return 0 when in fact it is more
}
});
`

I can , however, access the children of any Mutable node when it is not one of the root leafs (here users and messages).
Am I doing something wrong here?

What's the best solution to run an atomic transaction on a top-level node?

best regards

@google-oss-bot
Copy link

@google-oss-bot google-oss-bot commented Aug 11, 2018

Hey there! I couldn't figure out what this issue is about, so I've labeled it for a human to triage. Hang tight.

@google-oss-bot
Copy link

@google-oss-bot google-oss-bot commented Aug 11, 2018

Hmmm this issue does not seem to follow the issue template. Make sure you provide all the required information.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.