0

so I'm working with boolean data for when content is uploaded to Firestore.

var isBlue: Bool = false

I've structured my code for when isBlue is false, I will not write the value to the database as I thought it's pretty useless and you get charged for writes.

So now I'm on to querying data, is it possible to query fields/keys that may not even exist to avoid & limit overhead?

I know I can do it on the client-side and filter data, however, this does result in unnecessary reads. Or would better practise be to just write each value to the database regardless if they're nil?

Frank van Puffelen
  • 565,676
  • 79
  • 828
  • 807
SwiftUser
  • 555
  • 6
  • 17
  • 1
    "is it possible to query fields/keys that may not even exist?" No, this is currently not possible. See https://stackoverflow.com/search?q=%5Bgoogle-cloud-firestore%5D+query+non-existing+field (didn't find a good single answer yet). It's partially covered in https://firebase.google.com/docs/firestore/query-data/queries#query_limitations under "Queries with a `!=` clause are not supported. " – Frank van Puffelen Sep 10 '20 at 18:59
  • @FrankvanPuffelen Cos I guess I just have to write the data regardless of the values to limit overhead. Swings and roundabouts I guess. Appreciate the help. – SwiftUser Sep 10 '20 at 19:03
  • 1
    No problem. I'll close against the link I provided for now. – Frank van Puffelen Sep 10 '20 at 19:35

0 Answers0