【发布时间】:2018-10-20 06:09:25
【问题描述】:
我正在遵循 Firestore 存储数组的说明: https://firebase.google.com/docs/firestore/solutions/arrays
现在我想做的是推送到这张地图。例如现在我有:
Contacts
contact1: true
但我想添加或删除联系人,例如:
Contacts
contact1: true
contact2: true
我已尝试获取联系人地图并使用推送方法,但我认为这不会起作用,因为它不是传统数组。例如:
this.afs
.doc(`groups/${group.id}`)
.ref.get()
.then(doc => {
let contacts: Array<any> = doc.data().contacts;
contacts.push({ // error here as push is not a function
[contactId]: true
});
console.log(contacts);
});
有没有更简单的方法来做到这一点 - 我错过了什么?
【问题讨论】:
标签: angular firebase google-cloud-firestore angularfire2