Sulman Azhar
Sulman Azhar

Reputation: 1079

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

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

Upvotes: 0

Views: 772

Answers (1)

Dharmaraj
Dharmaraj

Reputation: 50830

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.

Upvotes: 1

Related Questions