使用 AngularFire2 检查用户列表中是否存在电子邮件
Check if email exists in user list using AngularFire2
我想检查在 Firebase 数据库中是否存在一个拥有 email = someemail@gmai.com 的用户。
我使用此功能并在 10 分钟后在我的 PC 中下载了 50MB 的数据,我得到一个存在的响应。有什么方法可以让我得到不到 5 秒的时间,我不想等 10 分钟。
在 PHP 中就像
SELECT FROM ALL USERS WERE EMAIL = 'george@gmail.com'
这是数据库:
"users" : {
user: {
"email" : "george@gmail.com",
"custom_id" : 534253,
"description" : "some small description"
},
1754: {
"email" : "natassa@gmail.com", <---- i want to find if this email from 5000 users exist in database and if exist i want to return true
"custom_id" : 110571,
"description" : "some small description"
},
1755: {
"email" : "george@gmail.com",
"custom_id" : dsgfsdfds,
"description" : "some small description"
},
}
此函数在 10 分钟后给我回复:
check_if_email_exist(email: string) {
this.users = this.db.list('/user', { query: {
orderByChild: 'email',
equalTo: x,
limitToLast: 10,
}} ) as FirebaseListObservable<Product[]>;
console.log(this.users);
return this.users;
}
天哪,我发现 https://whosebug.com/users/209103/frank-van-puffelen 的问题是关于 index 的,当我查看 chrome 控制台时,我发现警告说了一些事情关于索引,当我查看数据库规则时,我明白缺少什么
我在数据库规则中添加这个
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"needs": {
".read": "true",
".write": "auth != null",
".indexOn": "name"
},
"brands": {
".read": "true",
".write": "auth != null",
".indexOn": "name"
},
"products": {
".read": "true",
".write": "auth != null",
".indexOn": "custom_id" <========== This line you want
}
}
}
我想检查在 Firebase 数据库中是否存在一个拥有 email = someemail@gmai.com 的用户。
我使用此功能并在 10 分钟后在我的 PC 中下载了 50MB 的数据,我得到一个存在的响应。有什么方法可以让我得到不到 5 秒的时间,我不想等 10 分钟。
在 PHP 中就像
SELECT FROM ALL USERS WERE EMAIL = 'george@gmail.com'
这是数据库:
"users" : {
user: {
"email" : "george@gmail.com",
"custom_id" : 534253,
"description" : "some small description"
},
1754: {
"email" : "natassa@gmail.com", <---- i want to find if this email from 5000 users exist in database and if exist i want to return true
"custom_id" : 110571,
"description" : "some small description"
},
1755: {
"email" : "george@gmail.com",
"custom_id" : dsgfsdfds,
"description" : "some small description"
},
}
此函数在 10 分钟后给我回复:
check_if_email_exist(email: string) {
this.users = this.db.list('/user', { query: {
orderByChild: 'email',
equalTo: x,
limitToLast: 10,
}} ) as FirebaseListObservable<Product[]>;
console.log(this.users);
return this.users;
}
天哪,我发现 https://whosebug.com/users/209103/frank-van-puffelen 的问题是关于 index 的,当我查看 chrome 控制台时,我发现警告说了一些事情关于索引,当我查看数据库规则时,我明白缺少什么
我在数据库规则中添加这个
{
"rules": {
".read": "auth != null",
".write": "auth != null",
"needs": {
".read": "true",
".write": "auth != null",
".indexOn": "name"
},
"brands": {
".read": "true",
".write": "auth != null",
".indexOn": "name"
},
"products": {
".read": "true",
".write": "auth != null",
".indexOn": "custom_id" <========== This line you want
}
}
}