英文:
Firebase RT Database Query on field value hash equality
问题
我有一个Firebase实时数据库,其中用户的电子邮件存储在子字段中,例如:
/users/00Vho6lTQke46IqpRv0D5dw6DXs2/email -> user@email.com
我想要进行一次查询,根据电子邮件地址的MD5哈希获取用户。例如,MD5('user@email.com') -> 'b58c6f14d292556214bd64909bcdb118'
。
我没有用户的电子邮件地址,我只有MD5哈希。是否可以使用MD5函数来将电子邮件字段转换为MD5并进行查询?
英文:
I have a Firebase Realtime Database with users and the email is stored in a child field, for example:
/users/00Vho6lTQke46IqpRv0D5dw6DXs2/email -> user@email.com
I want to query once and get a user based on the MD5 hash of the email address. For example, MD5('user@email.com') -> 'b58c6f14d292556214bd64909bcdb118'
.
I don't have the email address of the user, I only have the MD5 hash. Is it possible to query using an MD5 function to transform the email field to MD5 and query on that?
答案1
得分: 1
不可以,除非您将MD5保存为数据库中的字段。如果这样做,您将能够使用MD5进行查询。您的模式应如下所示:
db
|
--- users
|
--- 00Vho6lTQke46IqpRv0D5dw6DXs2
|
--- email: "user@email.com"
|
--- md5: "b58c6f14d292556214bd64909bcdb118"
查询应如下所示:
val query = db.child("users").orderByChild("md5").equalTo("b58c6f14d292556214bd64909bcdb118");
英文:
> Is it possible to query using an MD5 function to transform the email field to MD5 and query on that?
No, unless you save the MD5 as a field inside the database. If you do that, you'll be able to query using the MD5. Your schema should look like this:
db
|
--- users
|
--- 00Vho6lTQke46IqpRv0D5dw6DXs2
|
--- email: "user@email.com"
|
--- md5: "b58c6f14d292556214bd64909bcdb118"
And the query should look like this:
val query = db.child("users").orderByChild("md5").equalTo("b58c6f14d292556214bd64909bcdb118");
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论