Rodrigo
Rodrigo

Reputation: 391

Firestore query by document Id and another property

I want to know if it is possible to do the following query, using the Id of the document and another property.

await firestore
  .collection('organizations')
  .doc(props.organizationId)
  .where('members', 'array-contains', userId)

Upvotes: 0

Views: 311

Answers (1)

Frank van Puffelen
Frank van Puffelen

Reputation: 599906

You can use FieldPath.documentId() to filter on the document ID in a query. So:

await firestore
  .collection('organizations')
  .where(firebase.firestore.FieldPath.documentId(), '==', props.organizationId)
  .where('members', 'array-contains', userId)

Upvotes: 2

Related Questions