firebase - 使用 Firebase 中的多个值检索 id
问题描述
我想检索项目 ID 并使用项目其他值将其设置为变量。根据这张图片(“get id where Brand="Manchee" and ItemName="Cream Cracker" and SubCategory="100g" ")如何写这个函数
解决方案
在这里您可以尝试此解决方案。我认为您想查询数据库,以便您可以根据变量值对数据库进行查询。只需在此查询中传递键和值,您就可以将所有数据驻留在表中属于此查询。
var ref = firebase.database().ref("items");
ref.orderByChild("itemName").equalTo('Manchee').once("value", (items : any)=> {
console.log(items.key);
console.log(items.val());
let itemArray: any = [];
items.forEach((item) => {
itemArray.push({
key: item.key,
});
});
this.items = itemArray;
console.log("Prescription Data: ", itemArray);
});
推荐阅读
- javascript - 如何解决问题:Uncaught (in promise) TypeError: promisify is not a function?
- asp.net-core - 当我们在 Asp.Net Core 3.1 中使用 Ajax 时,我们如何将原始值(字符串,int)绑定到动作的参数中?
- javascript - 注意:未定义的索引:在 $_FILES[audio_data]
- javascript - 在Javascipt中从字符串中的数组中搜索项目?
- wordpress - 将尾注转换为超链接以导出到 Wordpress
- java - Clickhouse Exception Code 1002 主机端口响应失败
- c++ - 硬币变化:找出重现给定总和的方法的数量
- mule - Dataweave 数据库输出到 CSV 响应
- c# - 为什么EventCallback类型的事件可以
分配 void Foo(DateTime dt) 或 void Foo()? - unity3d - 将 Dicom 图像像素值转换为 Unity 颜色