【发布时间】:2019-12-20 07:33:31
【问题描述】:
我的节点后端连接到 Firestore。我需要执行这个 MySQL 等效查询:
SELECT * FROM offer WHERE zip = '..' AND category = '...' AND status != 1 ORDER BY ..
到目前为止,我尝试了以下 Firebase 查询:
const docRef = db.collection('ads');
await docRef.where('status', '<', 4).where('status', '>', 5).orderBy('status')
.where('zip', '==', searchTerm).where('subCategory', '==', subCategory).orderBy('createdAt')
此查询返回空数组。我是 Firebase 的新手。
【问题讨论】:
-
您的查询正在检查小于 4 和大于 5 的状态。根据您的 MySQL 查询,我认为您想要
where('status', '!=', 1) -
@jmalenfant Firebase 没有不等式(
'<>'或'!=')operator,可用于where(...)。 -
@samthecodingman 奇怪。他可以只使用
.query()然后使用SQL,对吗? -
为了保持 Firestore 查询的性能,它们只是不受支持。看看this answer。
标签: node.js firebase google-cloud-firestore