问题
I want to create a login system , when the user logs in, based on the logged in users email id, I want to retrieve the EID.
The JSON structure I want is:
{
"joel@dept.com":
{
"EID":"0153"
},
"Stan@dept.com":
{
"EID":"0163"
}
}
I tried importing the JSON file with above structure into the Firebase projects database, but got an error suggesting "./ ..." cannot be a part of key.
回答1:
i faced the same constraints and i replaced '.' with '__dot__' to make email id as a key.
回答2:
Replacing one character with another may lead to confusion and may cause critical issues in future.
For the instance, replacing . with _DOT_ may work for now. Say in future you want to get back the original email for some verification; [no big deal] I can replace _DOT_ back with .. This fails if someone has the email actual._DOT_@actualdot.com
The solution is to use email hash. I prefer md5 at the moment.
So the structure should be:
{
"<md5 hash of 'joel@dept.com'>": {
"EID":"0153"
},
"<md5 hash of 'Stan@dept.com'>": {
"EID":"0163"
}
}
回答3:
Firebase does not support characters like .[]{} hence if you want to produce in using the email as the primary key then you will have to replace the .replace(".",",")
来源:https://stackoverflow.com/questions/41713039/can-we-have-email-id-as-key-in-firebase-database