具有特殊字符的Firestore查询属性 [英] Firestore Query Properties with special characters

查看:44
本文介绍了具有特殊字符的Firestore查询属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个联系人集合,其结构如下:

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

名称:"XPTO"电子邮件:{susan@xpto.com:'Susan',fred@xpto.com:'Fred'}

但是查询不会返回结果: db.firestore().collection('contacts').where('emails.susan@xpto.com','==','Susan').get().then(...

But the query will not return result: db.firestore().collection('contacts').where('emails.susan@xpto.com', '==', 'Susan').get().then(...

因为在"susan@xpto.com"上有一个点

Because of the dot at "susan@xpto.com"

如何逃脱圆点?

我尝试了`` [] ,但没有用.

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', 'susan@xpto.com'), '==', 'Susan').

这篇关于具有特殊字符的Firestore查询属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆