简体   繁体   中英

How to use email as a ID of your firebase data and retrieve data according to it

I am trying to make a app where user can login with email and password. But i have saved its credentials with the ID (user ID) how can I retrieve data according to my email not my user ID.

火力地堡数据库

When I try to retrieve data with the "email" in my query it is showing the error

Query check=db_refer.orderByChild("email").equalTo(emails);
        check.addListenerForSingleValueEvent(new ValueEventListener() {
            @Override
            public void onDataChange(@NonNull DataSnapshot snapshot) {
                if(snapshot.exists()){
                    String db_pass=snapshot.child(emails).child("pass").getValue(String.class);
                    if(db_pass.equals(passs)){
                        Toast.makeText(SignIn.this, "SIGNED IN", Toast.LENGTH_SHORT).show();
                    }
                    else{                                  Toast.makeText(SignIn.this, db_pass+" and "+passs, Toast.LENGTH_SHORT).show();
                        Toast.makeText(SignIn.this, "NOT SIGNED IN", Toast.LENGTH_SHORT).show();

                    }
                }
            }

            @Override
            public void onCancelled(@NonNull DatabaseError error) {
            }
        });
    }
});

This is the error message which my compiler is showing:

W/PersistentConnection: pc_0 - Using an unspecified index. Your data will be downloaded and filtered on the client. Consider adding '".indexOn": "email"' at Workers to your security and Firebase Database rules for better performance

The error message says that the filtering of the data is currently being done inside the Android application, instead of on the server. This is highly unscalable, so you'll want to fix that by adding an index in your database rules:

{
  "rules": {
    ...
    "Workers": {
      ".indexOn": "email"
    }
  }
}

I recommend searching for any error messages that you get going forward, as this error came up before .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM