0

I have a parameter named parm which can be a document name, OR a field name in a document. I would like to check in a single query both cases.

CollectionA
  docA
  docB
  docC

and inside a document

 docA
   brand
      nick

So currently I can check for a document with a certain nick, with :

  db.collection("CollectionA").where("brand.nick", "==", parm)

Given that parm can now also be a document name (docB), I would like to add an OR to this query, to also check first if there is a document with that name in parm, if so return that document, otherwise, check for a doc with brand.nick if exist.

Doug Stevenson
  • 268,359
  • 30
  • 341
  • 380
hkrlys
  • 333
  • 1
  • 10
  • @doug read that already, my question is a little bit different, don't read only the title. I am asking how to first check a document name, and then a query, in one shot. – hkrlys Dec 18 '19 at 21:24
  • 1
    You're describing essentially the same situation as the duplicate. It requires two queries. Firestore doesn't offer a logical OR across fields (the ID of the document is essentially a field with a special meaning). – Doug Stevenson Dec 18 '19 at 21:34
  • ok thank you! will change the structure. – hkrlys Dec 19 '19 at 12:15

0 Answers0