我有一个联系人集合,其结构如下:
name: 'XPTO Company',
emails: {
[email protected]: { name: 'Susan', text: 'manager' },
[email protected]: { name: 'Fred', text: 'marketing' }
}
如何通过电子邮件检索文档'[电子邮件受保护]'
就像是:
firebase.firestore().collection('contacts')
.where(new firebase.firestore.FieldPath('emails', email), '==', true).get()
.then(snap => {
})
您可以添加属性id
它将电子邮件地址保存到您的电子邮件对象。并替换 '.'在电子邮件对象键中带有“-”,例如susan@xpto-com
,这样你的数据结构如下所示:
name: 'XPTO Company',
emails: {
susan@xpto-com: { id: '[email protected]', name: 'Susan', text: 'manager' },
fred@xpto-com: { id: '[email protected]', name: 'Fred', text: 'marketing' }
然后您可以通过电子邮件检索文档'[电子邮件受保护]' 这样:
firebase.firestore().collection('contacts')
.where('[email protected]', '==', '[email protected]').get()
.then(snap => {
})
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)