Firestore select where not null

I use firebase to manage my project and I cannot create a query with a where clause where some value is not null.

Example: I have a team of employees. Each has a list of equipment as an object, where the key is the identifier of the equipment, and the value is color.

user = {
    firstName: 'blabla',
    lastName: 'bloblo',
    equipments: {
        123: 'blue',
        124: 'red'
    }
}

I would like to get all the employees who have certain equipment in the equipment. Let's say 123.

This applies to Select * from Employees, where .123 equipment is not null. I tried:

firestore.collection('employees').where(`equipments.${equipmentId}`, '!=', null)

but it does not work.

I can not make it work. Can you help me.

+6
source share
2 answers

Firestore " ". , , , , String, null. Firestore , String where().

\uf8ff. Unicode. Unicode, , String:

firestore.collection('employees').where('equipments.${equipm‌​entId}', '<', '\uf8ff')

, "" (empty String):

firestore.collection('employees').where('equipments.${equipm‌​entId}', '>', '')
+15

(, .exists), true

0

Source: https://habr.com/ru/post/1687712/


All Articles