0

From: https://firebase.google.com/docs/firestore/query-data/queries

// Create a reference to the cities collection

var citiesRef = db.collection("cities");

// Create a query against the collection.

var query = citiesRef.where("state", "==", "CA");

From documentation it is possible to query collection. (CollectionReference type)

But I am having document that contains array of references, which has type DocumentReference[] and I am curious is it possible to achieve query over DocumentReference[]? Something like:

someCities : DocumentReference[];

someCities.where("street", "==", "School street")

1 Answer 1

1

If you want to query a DocumentReference array type field, you will have to use an array-contains query, and pass a DocumentReference type object to it. It won't work with a string.

const ref = db.collection('coll').doc('doc');
db.collection('coll').where('refField', 'array-contains', ref);
Sign up to request clarification or add additional context in comments.

1 Comment

Thank you for the fast reply, not actualy what I expected, but I solved a problem with for loop through my array of reference with calling get() function to get data what reference are representing.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.