Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firestore Query Properties with special characters

I've a collection with contacts with a structure like:

name: 'XPTO' emails: { [email protected]: 'Susan', [email protected]: 'Fred' }

But the query will not return result: db.firestore().collection('contacts').where('[email protected]', '==', 'Susan').get().then(...

Because of the dot at "[email protected]"

How to escape the dot?

I've tried `` and [ ] and didn't work.

like image 360
InfoStatus Avatar asked Dec 18 '22 00:12

InfoStatus


1 Answers

The documentation that suggests you should escape fields using backticks is actually not correct. It's in the process of being fixed. Instead, you should use FieldPath to build a path to the field to query:

db.firestore()
.collection('contacts')
.where(new FieldPath('emails', '[email protected]'), '==', 'Susan').
like image 149
Doug Stevenson Avatar answered Dec 29 '22 00:12

Doug Stevenson