我使用Firebase函数创建一个函数,允许通过在Firebase实时数据库中创建目录来完成用户配置文件,如下所示:
{
users:
{
AeknQrtMIyPpC4EQDPNQYvQUxCA3:
{
username : test
profilePicture : https://url.com/1
}
AekyPpC4EQnQrtMIQUxCA3yPpC4v:
{
username : test2
profilePicture : https://url.com/2
}
}
}
该函数将userId,username和profilePicture作为参数 .
我希望能够检查(当调用函数时)用户想要使用的用户名是否存在于数据库中 .
我已阅读此文档但我无法应用它:https://firebase.google.com/docs/database/web/lists-of-data https://firebase.google.com/docs/reference/js/firebase.database.Query
非常感谢你的帮助 .
1 回答
要检查用户名是否存在:
更多信息:
https://firebase.google.com/docs/reference/js/firebase.database.DataSnapshot#exists