以前,我的数据库已成功更新,但是当我需要将文档上传到存储设备后,我的数据库停止了更新。字段保持不变。
首先,我删除旧文件,然后上传新文件并替换数据库中的文件名。并更新所有数据。
文件已成功更新,但数据未更新
export const UpdateProject = data => async (
dispatch,
getState,
{ getFirestore, getFirebase }
) => {
const firestore = getFirestore();
const firebase = getFirebase();
try {
await firestore
.collection("Mission")
.where("idMission", "==", data.idMission)
.get()
.then(snap => {
snap.forEach(doc => {
let project = doc.data();
firebase
.storage()
.refFromURL(
`gs://nospace-92826.appspot.com/Missions/${project.idMission}/${project.NameDoc}`
)
.delete();
});
});
await firebase
.storage()
.ref(`Missions/${data.idMission}/` + data.document.name)
.put(data.document);
data.NameDoc = data.document.name;
delete data.document;
await firestore
.collection("Mission")
.doc(data.idMission)
.update({ ...data });
} catch (err) {}
};
可更新字段不能不确定,我认为发送时会忽略它们
我只是删除它们
delete FormData.LinkBoss
delete FormData.LinkWorker
delete FormData.TextDone
delete FormData.MissionDoneTitle