【发布时间】:2019-06-23 10:44:11
【问题描述】:
我想通过数组中的属性“id”查询特定对象并删除/删除整个对象。这可以通过firestore实现吗?
我的 Firestore 结构如下所示:
现在我有一个名为removeCard() 的函数,它接收作为firestore 中的文档ID 的docId 和作为对象内的属性“id”值的cardId。
removeCard() 函数:
export const removeCard = (retroId, cardId) => {
return (dispatch, getState, { getFirestore }) => {
// make async call to database
const firestore = getFirestore();
firestore.collection('retros').doc(retroId).update({
// firestore query to remove/delete this card.
}).then(() => {
dispatch({ type: 'DELETE_CARD_SUCCESS' });
}).catch(err => {
dispatch({ type: 'DELETE_CARD_ERROR' }, err);
});
}
};
但我不知道如何执行此查询,或者是否可以使用 Firestore。任何帮助表示赞赏。请告诉我是否应该提供更多信息以使我的问题更清楚。
【问题讨论】:
标签: reactjs firebase google-cloud-firestore