Current Firebase DB Structure:
What I'm trying to achieve:
- Search in any "promotions" child in all my places for a coupon equalTo something.
- If found, update its "limit" parameter by decreasing it by -1
My current code:
mDatabase = FirebaseDatabase.getInstance().getReference("Place");
Query query = mDatabase.child("promotions").orderByChild("coupon").equalTo("FREEBIGMAC");
query.addListenerForSingleValueEvent(new ValueEventListener() {
@Override
public void onDataChange(DataSnapshot dataSnapshot) {
for (DataSnapshot snapshot: dataSnapshot.getChildren()) {
// Not able to find anything here
}
}
@Override
public void onCancelled(DatabaseError databaseError) {
System.out.println("The read failed: " + databaseError.getMessage());
}
});
I have been trying to find a similar example under StackOverFlow but I haven't been able to find my exact case. I would really appreciate your help!