按月Firestore过滤器数据

I'm trying to filter a data collection by month. But it's giving me an error TypeError: _this._firestore.collection('Employee').orderByChild is not a function. Below is my code and database structure

enter image description here

const month = 5
firestore.collection('Employee').orderByChild("month").equalTo(month).once('value',snapshot=>{
                snapshot.forEach((childSnapshot)=>{
                var users = childSnapshot.key;
                })
            })
评论
买依薇
买依薇

What you're showing is not valid Firestore syntax at all. It looks like you're mixing up Firestore queries with Realtime Database queries. There is no orderByChild on a Firestore query, but there is on Realtime Database queries. On top of that, you have no field called "month" in the document you're showing here, so it's not clear at all what you're trying to do with this query.

If you're using Firestore, I strongly suggest you familiarize yourself with Firestore queries using the documentation. Ignore any documentation about Realtime Database.

点赞
评论