I am working on a small iOS app, using Swift and Cloud Firestore database.
I have collection (A) each document of which contains field with reference to another collection(B). Why question is how to query that field?
- I am getting references to B by performing a simple query
let doc = "merchant"
let ref = db.collection(doc).whereField("subscribers",arrayContains: Session.current.user!.uid!)
- Then what I am trying to do is to compare the value from
ref
with reference field from collection A like so
db.collection("appointment").whereField("merch_ref", isEqualTo: ref).addSnapshotListener { snapshot, error in
if let snap = snapshot {
for item in snap.documents {
print(item.data())
}
}
}
When I execute that I'm getting an error
Terminating app due to uncaught exception 'FIRInvalidArgumentException', reason: 'Unsupported type: FIRQuery'
Can you point me in the right direction
Thanks