查询基于Firebase中的多个where子句{"movies": {
"movie1": {
"genre": "comedy",
"name": "As good as it gets",
"lead": "Jack Nicholson"
},
"movie2": {
"genre": "Horror",
"name": "The Shining",
"lead": "Jack Nicholson"
},
"movie3": {
"genre": "comedy",
"name": "The Mask",
"lead": "Jim Carrey"
}
}
}我是Firebase的新手。我如何可以检索从上面的数据结果,其中genre = 'comedy'与lead = 'Jack Nicholson'?我有什么选择?
4 回答
慕婉清6462132
TA贡献1804条经验 获得超2个赞
我写了一个个人库,允许您按多个值排序,所有订单都在服务器上完成。
认识Querybase!
Querybase接收Firebase数据库引用和您要索引的字段数组。当您创建新记录时,它将自动处理允许多次查询的密钥的生成。需要注意的是,它只支持直接等价(不小于或大于)。
const databaseRef = firebase.database().ref().child('people');const querybaseRef = querybase.ref(databaseRef, ['name', 'age', 'location']); // Automatically handles composite keysquerybaseRef.push({ name: 'David', age: 27, location: 'SF'});// Find records by multiple fields// returns a Firebase Database refconst queriedDbRef = querybaseRef .where({ name: 'David', age: 27 });// Listen for realtime updatesqueriedDbRef.on('value', snap => console.log(snap));
长风秋雁
TA贡献1757条经验 获得超7个赞
ref.orderByChild("lead").startAt("Jack Nicholson").endAt("Jack Nicholson").listner....
添加回答
举报
0/150
提交
取消