Each user in my firestore database has a bunch of contacts. I show each user their contacts with the following query.
firebase
.firestore()
.collection('users')
.doc(userId)
.collection('contacts')
.orderBy('lastContacted')
Now I want to introduce a new feature that lets people archive contacts.
The simplest way to do this would be to add a "status" key to the contacts and set it to "active" or "archived".
If I do this, is there any way to query for all the contacts that don't have the "status" key?
I thought about assigning the status key a value of 1 or 0 instead. I thought this would let me try the following:
firebase
.firestore()
.collection('users')
.doc(userId)
.collection('contacts')
.where("status", "<", "1")
.orderBy('lastContacted')
...but that does not work :(
Can I run a firestore query on a key that doesn't exist?
I want to return all contacts that don't yet have a status key.
It's an existing database so I don't want to go back and add the status field to every single contact in the database. Is there any way to avoid doing this?
I realise I can pull all contacts and handle the filtering on the client. I would prefer not to do this, this question is specific to fetching the data from firestore.