【发布时间】:2021-11-16 19:20:33
【问题描述】:
我正在尝试为我的应用程序创建一个过滤器 它将按数据的类别进行过滤,但我也想按其评级对它们进行排序,较高的评级将位于顶部。 我写了以下代码,但是 orderby() 函数有问题。
const snapshot = await firebase.firestore().collection('Locations').where(
"category", "==", type).orderBy("rating").get();
if (snapshot.empty){
console.log('No matching documents');
return;
}
snapshot.forEach(doc=> {
locList.push(doc.data());
})
【问题讨论】:
-
你得到什么回应?
标签: javascript firebase google-cloud-firestore