So this is the situation.
I have a database which has a Users collection. In some users I have a userType
property, but some users don't have this property. userType
can be equal to both person
and company
. How can I pick only the users that have the userType
property? I could do something like this:
let persons = await admin.database().ref('Users').orderByChild('userType').equalTo('person').once('value');
persons = await persons.val();
let companys = await admin.database().ref('Users').orderByChild('userType').equalTo('company').once('value');
companys = await companys.val();
let users = persons + companys;
but this is just ugly. How can I filter this using a firebase query?
I found this answer Query based on multiple where clauses in Firebase but it's from 2014, so I hoped that maybe some improvement was made in 4 years.