Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/hibernate/5.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
Google cloud firestore Firestore按月筛选数据_Google Cloud Firestore - Fatal编程技术网

Google cloud firestore Firestore按月筛选数据

Google cloud firestore Firestore按月筛选数据,google-cloud-firestore,Google Cloud Firestore,我正在尝试按月筛选数据收集。但是它给了我一个错误类型error:_this._firestore.collection'Employee'。orderByChild不是一个函数。下面是我的代码和数据库结构 您显示的根本不是有效的Firestore语法。看起来您将Firestore查询与实时数据库查询混为一谈。Firestore查询中没有orderByChild,但实时数据库查询中没有orderByChild。最重要的是,在这里显示的文档中没有名为month的字段,因此根本不清楚如何处理此查询 如

我正在尝试按月筛选数据收集。但是它给了我一个错误类型error:_this._firestore.collection'Employee'。orderByChild不是一个函数。下面是我的代码和数据库结构


您显示的根本不是有效的Firestore语法。看起来您将Firestore查询与实时数据库查询混为一谈。Firestore查询中没有orderByChild,但实时数据库查询中没有orderByChild。最重要的是,在这里显示的文档中没有名为month的字段,因此根本不清楚如何处理此查询


如果您正在使用Firestore,我强烈建议您使用熟悉Firestore查询。忽略任何有关实时数据库的文档。

firestore的等效语法是什么?请查看答案中文档的链接。我已经扫描了完整的文档,只看到了where示例。where'birthDate','>',startDate。如果要按月份筛选,则不按月份筛选日期。您必须对包含月份的字段进行筛选。如果该字段不存在,则必须创建它。
const month = 5
firestore.collection('Employee').orderByChild("month").equalTo(month).once('value',snapshot=>{
                snapshot.forEach((childSnapshot)=>{
                var users = childSnapshot.key;
                })
            })