因此,我正在嘗試在我的firebase函數中使用批處理寫入來以500個批處理的批處理我的寫入。但是,由于某種原因,我收到錯誤“錯誤:無法修改已提交的 WriteBatch”,并且似乎無法發現我做錯了什么。它正在存儲前幾個結果,但之后它在我的云函數日志中給了我錯誤。任何建議將不勝感激= D messages.forEach((item, index) => { var all = _.find(item.parts, { which: "" }); var id = item.attributes.uid; var idHeader = "Imap-Id: " + id + "\r\n"; // eslint-disable-next-line handle-callback-err simpleParser(idHeader + all.body, (err, mail) => { // access to the whole mail object console.log(mail.subject); console.log(mail.html); let newDate = mail.date.valueOf(); batch.set( docRef, { Emails: admin.firestore.FieldValue.arrayUnion( JSON.stringify({ subject: mail.subject, body: mail.text, date: newDate, from: mail.from, }) ), //.... }, { merge: true } ); if ( (index % 500 === 0 && index > 0) || index === messages.length - 1 ) { return batch.commit().then(() => { return console.log("SUCCESS"); }); } }); });
“錯誤:無法修改已提交的 WriteBatch”,嘗試在 firebase 函數中使用批處理寫入時
三國紛爭
2022-08-04 10:08:25