Home > Enterprise >  How can i use .where in firebase?
How can i use .where in firebase?

Time:11-05

I have this part of code to get a collection firebase

const db = getFirestore(app)
const getCollection = name => collection(db, name)
const query = await getCollection(db, 'movies').where('name', '==', 'any')

i am getting error in .where is not a function, what is the wrong?

Unhandled Rejection (TypeError): collection.where is not a function

CodePudding user response:

You're using the new modular SDK, where all functions are top-level.

To create a query, do:

const query = query(collection, where('name', '==', value))

Also see the Firebase documentation on building queries.

  • Related