亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

“錯誤:無法修改已提交的 WriteBatch”,嘗試在 firebase 函數中使用批處理寫入時

“錯誤:無法修改已提交的 WriteBatch”,嘗試在 firebase 函數中使用批處理寫入時

三國紛爭 2022-08-04 10:08:25
因此,我正在嘗試在我的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");                });              }            });          });
查看完整描述

1 回答

?
慕沐林林

TA貢獻2016條經驗 獲得超9個贊

批處理過程需要有兩個部分,一個 main 函數和一個來自每個批處理的回調。問題是,一旦為第一個批處理提交了批處理,您就試圖重新聲明批處理進程。創建一個新批處理或在特定函數中分離它,如文檔示例。

查看完整回答
反對 回復 2022-08-04
  • 1 回答
  • 0 關注
  • 85 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號