获取父 uid 数据
Get parent uid data
我正在尝试获取 UID 数据。
这是我的 Firebase 数据库结构
和规则
我在 .ts 中的代码
firebase.database().ref('/appointment/').orderByChild('keys').equalTo(this.user.$key).once('value').then(snapshot => {
snapshot.forEach(function(child) {
console.log(child.key);
});
})
但我在控制台中得到了这个
FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "keys" at /appointment to your security rules for better performance
拜托,知道我做错了什么吗?我怎样才能得到uid??
您在数据库中没有名为 key
的 child,这是您拥有的:
appointment
userid
randomKey
almt:...
gr:...
如果要检索当前用户 ID,请执行以下操作:
var user = firebase.auth().currentUser;
var uid=user.uid;
如果你只想从数据库中检索它,那么这样做:
firebase.database().ref('/appointment/').once('value').then(snapshot => {
snapshot.forEach(function(child) {
console.log(child.key);
});
})
这将在 appointment
的直接 child 内循环,而 child.key
将检索 uid
我正在尝试获取 UID 数据。
这是我的 Firebase 数据库结构
和规则
我在 .ts 中的代码
firebase.database().ref('/appointment/').orderByChild('keys').equalTo(this.user.$key).once('value').then(snapshot => {
snapshot.forEach(function(child) {
console.log(child.key);
});
})
但我在控制台中得到了这个
FIREBASE WARNING: Using an unspecified index. Consider adding ".indexOn": "keys" at /appointment to your security rules for better performance
拜托,知道我做错了什么吗?我怎样才能得到uid??
您在数据库中没有名为 key
的 child,这是您拥有的:
appointment
userid
randomKey
almt:...
gr:...
如果要检索当前用户 ID,请执行以下操作:
var user = firebase.auth().currentUser;
var uid=user.uid;
如果你只想从数据库中检索它,那么这样做:
firebase.database().ref('/appointment/').once('value').then(snapshot => {
snapshot.forEach(function(child) {
console.log(child.key);
});
})
这将在 appointment
的直接 child 内循环,而 child.key
将检索 uid