我试图查询 Firestore 数据库中的集合并按日期过滤。我有一个时间戳字段,当名为“specicDate”的字段等于 now() 时,我需要获取结果。
app.get('/execute', async(req, res, next) => {
const snaps = await db.collection('notifications').where("specificDate", "==", new Date()).get()
const results= [];
snaps.forEach(snap => results.push(snap.data()));
res.status(200).json({results});
});
Run Code Online (Sandbox Code Playgroud)
无论任何组合,我都没有结果。如果我用“<”或“">”更改“==”,我就会得到结果。恐怕问题与时间有关,我想忽略这一点,我只关心年、月和日。下图展示了我的 firestore 收藏,其中只有一件 1 件。

我一直在研究,但我还不够幸运。
javascript firebase google-cloud-platform google-cloud-firestore