Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/firebase/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript Firestore云函数按日期查询_Javascript_Firebase_Google Cloud Firestore - Fatal编程技术网

Javascript Firestore云函数按日期查询

Javascript Firestore云函数按日期查询,javascript,firebase,google-cloud-firestore,Javascript,Firebase,Google Cloud Firestore,我试图查询Firestore数据库中的集合并按日期进行筛选。 我有一个Timestamp字段,当一个名为“specificDate”的字段等于now()时,我需要得到结果 无论任何组合,我都没有结果。如果我用“”更改“==”,我就有结果。 我担心这个问题与时间有关,我想忽略这一点,我只关心年、月、日。 下图展示了我的firestore收藏,其中只有一个1项目。 我一直在研究,但我还不走运。使用and查询为查询提供所需的范围。因为你不在乎精确地匹配时间,所以给它整个天数范围 var start

我试图查询Firestore数据库中的集合并按日期进行筛选。 我有一个Timestamp字段,当一个名为“specificDate”的字段等于now()时,我需要得到结果

无论任何组合,我都没有结果。如果我用“”更改“==”,我就有结果。 我担心这个问题与时间有关,我想忽略这一点,我只关心年、月、日。 下图展示了我的firestore收藏,其中只有一个1项目。


我一直在研究,但我还不走运。

使用and查询为查询提供所需的范围。因为你不在乎精确地匹配时间,所以给它整个天数范围

var start = new Date();
start.setHours(0,0,0,0);

var end = new Date(start.getTime());
end.setHours(23,59,59,999);

const snaps = await db.collection('notifications').where("specificDate", ">=", start ).where("specificDate", "<=", end).get()
var start=newdate();
启动设定小时数(0,0,0,0);
var end=新日期(start.getTime());
完二〇〇四年十一月二十三日,五九九九,十九日(星期三)上午十一时三十分;

const snaps=await db.collection('notifications')。其中(“specificDate”,“>=”,start)。其中(“specificDate”,“使用AND查询为查询提供所需的范围。由于您不关心精确匹配时间,请为其提供整个天数范围

var start = new Date();
start.setHours(0,0,0,0);

var end = new Date(start.getTime());
end.setHours(23,59,59,999);

const snaps = await db.collection('notifications').where("specificDate", ">=", start ).where("specificDate", "<=", end).get()
var start=newdate();
启动设定小时数(0,0,0,0);
var end=新日期(start.getTime());
完二〇〇四年十一月二十三日,五九九九,十九日(星期三)上午十一时三十分;

const snaps=await db.collection('notifications')。其中(“specificDate”,“>=”,start)。其中(“specificDate”,“以下内容应使用Firestore时间戳的方法构建查询:

const timestamp = firebase.firestore.Timestamp.fromDate(
          new Date('2020-02-12 00:00:00')
        )

const snaps = await db.collection('notifications').where("specificDate", "==", timestamp).get()

下面应该使用Firestore时间戳的方法来构建查询:

const timestamp = firebase.firestore.Timestamp.fromDate(
          new Date('2020-02-12 00:00:00')
        )

const snaps = await db.collection('notifications').where("specificDate", "==", timestamp).get()

谢谢雷纳德·塔内克!!谢谢雷纳德·塔内克!!