Update without where

3

How can I make an increase only in the child period of all students enrolled in Firebase?

Ex: in SQL, I would use:

UPDATE alunos
SET periodo = periodo + 1 

Updating all students to their later period. How can I do it in Firebase?

    
asked by anonymous 20.10.2017 / 09:12

1 answer

2

I was able to accomplish what I needed by adapting the code below

DatabaseReference rootRef = FirebaseDatabase.getInstance().getReference();
DatabaseReference usersRef = rootRef.child("users");
ValueEventListener eventListener = new ValueEventListener() {
    @Override
    public void onDataChange(DataSnapshot dataSnapshot) {
        String true = "true";
        for(DataSnapshot ds : dataSnapshot.getChildren()) {
            ds.child("SubmitCheck").getRef().setValue(true);
        }
    }

    @Override
    public void onCancelled(DatabaseError databaseError) {}
};
usersRef.addListenerForSingleValueEvent(eventListener);

Source: link

    
21.10.2017 / 03:29