Home > Software engineering >  Query a collection to check if one map object exists and other doesn't exist on in firestore
Query a collection to check if one map object exists and other doesn't exist on in firestore

Time:12-31

I am trying to find a simple query where will be able to get all the documents where one map object property exists and one map object property doesn't exist. How can I do that

Here is the document on which I want to query. Basically, I want to query the collection where these conditions meet

enter image description here

CodePudding user response:

Currently there isn't any way to query documents based on existence of a field.

One work around is to use orderBy("userContributionData") in your query which will return documents where this field exists and then manually removing documents where subscriptionData field is missing.

Another way would be set default value of the field to null so you can use a where('field', '==', null) clause.

  • Related