尝试在 Firebase 实时数据库查询上使用 equalTo
我有以下节点:
attendanceOptions: {
uid1: '[email protected]',
uid2: '[email protected]'
}
我试图仅返回值等于的键和值。这是我的两次尝试。
const getMinistry = await admin.database().ref(`organization/${req.orgId}/attendanceOptions`)
getMinistry
.equalTo(req.memberUid)
.once('value', snapshot => {
functions.logger.log(snapshot.val())
});
这将返回空值 我也尝试过:
const getMinistry = await admin.database().ref(`organization/${req.orgId}`)
getMinistry
.orderByChild('attendanceOptions')
.equalTo(req.memberUid)
.once('value', snapshot => {
const data = snapshot.val();
functions.logger.log( `this is data: ${data}` )
return data;
});
日志是 this is data: null
在我的规则中我有:
"attendanceOptions": {
".indexOn": [".value"]
},
我在这里做错了什么?
I have the following node:
attendanceOptions: {
uid1: '[email protected]',
uid2: '[email protected]'
}
I'm trying to return only the key and value where value is equal to. These are my two attempts.
const getMinistry = await admin.database().ref(`organization/${req.orgId}/attendanceOptions`)
getMinistry
.equalTo(req.memberUid)
.once('value', snapshot => {
functions.logger.log(snapshot.val())
});
This returns null
I also tried:
const getMinistry = await admin.database().ref(`organization/${req.orgId}`)
getMinistry
.orderByChild('attendanceOptions')
.equalTo(req.memberUid)
.once('value', snapshot => {
const data = snapshot.val();
functions.logger.log( `this is data: ${data}` )
return data;
});
The log is this is data: null
In my rules I have:
"attendanceOptions": {
".indexOn": [".value"]
},
What am I doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
正确的语法是:
The correct syntax is: