Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to solve the TS type error when trying to get firebase data by using orderByChild?

I need to get all the players ordered by their points from Firebase(V9) Realtime Database.
I tried to fetch them as it is instructed in the docs.

But ref(db, 'usersPoints') throws this TypeScript error:

Argument of type 'DatabaseReference' is not assignable to parameter of type 'Query<unknown>'. Type 'DatabaseReference' is missing the following properties from type 'Query<unknown>': converter, type, firestore, withConverter

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Here is the code:

const db = getDatabase();
const playersByPoints = query(ref(db, "usersPoints"), orderByChild("points"));

>Solution :

It looks like you’re importing query from firebase/firestore, instead of firebase/database.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading