javascript - firebase get child by month of birthday
问题描述
I'm looking to make query in firebase to get all child by month of birthday. for e.g the month is april (04) so I want to get the user1,user2,user4 in my example
not sure if need to use in startAt query or what way to do it.
let month = '04';
firebase.ref('/UserTest').startAt(month).once('value',snapshot=>{
snapshot.forEach((childSnapshot)=>{
})
})
解决方案
You need to store a field for month alone, then you can use equal(month_here)
to be able to retrieve all users in month April:
firebase.ref('/UserTest').orderByChild("month").equalTo(month).once('value',snapshot=>{
snapshot.forEach((childSnapshot)=>{
var users = childSnapshot.key;
})
})
This var users = childSnapshot.key;
will retrieve the users
more info here:
https://firebase.google.com/docs/reference/js/firebase.database.Query
推荐阅读
- tensorflow2.0 - 将 tensorflow 模型转换为 tflite 输出一个我无法去量化的 int8
- python - 安装 conda 后,我在 Mac 上编写 python 的方式会发生什么变化?
- html - 如何在网页上随机放置元素
- excel - 使用 Excel VBA 导入 XML 数据
- c# - System.Text.Json 错误处理等效于 Newtonsoft.Json (json.net) JsonSerializerSettings
- r - 是否有可能以每列在 R 中成对的方式扩展和重组数据框?
- python - 我应该如何使用 python ctypes.CDLL 从 .so 调用函数?
- android - Toast.makeText 没有显示(不是 .show)
- python-3.x - diffeqpy 在 python 中使用 julia 很慢
- lit-element - 带 unpkg 的 Lit-Element 导入语句