2

i have documents in following format

uid_112 uid_232 uid_433 mid_232 kid_221

i want to retrieve all the doc with doc id starting from uid

like uid*

ann will get the results as following documents

firestore.instance.collection("col").where(doc_val , "isMasterString" ,"uid" )

zaid saeed
  • 125
  • 9

2 Answers2

2

I believe that is not possible in firestore. Perhaps you should change your implementation. Firstm I recommened using firestore auto ids in your document ids and store the uid list in array field of your document.

Refer to this structure

someCollection
    ATPawqV3XXehZn4W38fPPTXJ8 (document auto id)
         userIds (array field)
             0: uid_112
             1: uid_113 

Then in your query, you can do this.

//in kotlin
someCollection.whereArrayContains("userIds", "uid_112")
elbert rivas
  • 1,464
  • 1
  • 17
  • 15
1

There are no true wildcard queries for document ID in Firestore. In fact, it's not a very good idea to put data in document IDs. Queryable data should go in fields of documents.

What you should do in a field in your documents that help you make the queries you need. If you have three different types of documents, "uid", "kid", "mid", perhaps you should use that string as the value of a field in the document. If the field was called "type":

firestore
    .collection("col")
    .where("type" "==", "uid")
Doug Stevenson
  • 297,357
  • 32
  • 422
  • 441