问题描述
我有一个联系人集合,其结构如下:
I've a collection with contacts with a structure like:
名称:"XPTO"电子邮件:{[email protected]:'Susan',[email protected]:'Fred'}
但是查询不会返回结果: db.firestore().collection('contacts').where('[email protected]','==','Susan').get().then(...
But the query will not return result:db.firestore().collection('contacts').where('[email protected]', '==', 'Susan').get().then(...
因为在"[email protected]"上有一个点
Because of the dot at "[email protected]"
如何逃脱圆点?
我尝试了``
和 []
,但没有用.
I've tried ``
and [ ]
and didn't work.
推荐答案
建议您使用反引号转义字段的文档实际上是不正确的.它正在修复中.相反,您应该使用 FieldPath 来建立该字段的路径查询:
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').
这篇关于具有特殊字符的Firestore查询属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!