简体   繁体   中英

firebase where query not functioning

I'm trying to run the following query:

   const getAttendCount = fDB.ref(`organization/${uid}`);
   const query = getAttendCount.where('lastAttendanceCount', 'array-contains', date)
   .then(snapshot => console.log(snapshot.val()))

I get this error:

I have these values:

2020-02-11-PM: 
128
2020-02-16-AM: 
158
2020-02-16-PM: 
164

In the example above I wanted to get the records for 02-16 am and pm. So my solution was to do. where('lastAttendanceCount', 'array-contains', date)

UnhandledPromiseRejectionWarning: TypeError: getAttendCount.where is not a function

Obviously I'm doing something wrong but not sure what.

You're mixing up the APIs for two different database products.

Realtime Database doesn't have a where() method. That's only used with Firestore. If you want to query Realtime Database, you need to identify the node that you want to query, add an ordering to it, and use once() to fetch the results, as shown in the documentation . I suggest reviewing it.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM