![](/img/trans.png)
[英]Function execution took 540029 ms, finished with status: 'timeout'
[英]Firebase Function execution took 2794 ms, finished with status: 'ok' ,... but no change took place in Firestore
我正在嘗試使用 Cloud Functions 和 NodeJs 更新 Firestore 中嵌套子集合中的所有文檔。
collection().doc().collection.doc().collection().doc()
/timeline/105358539742688769892/publisherId/105358539742688769892/posts/29b975f2-0d53-4e06-8365-3d5442355a78
這是我的代碼。
exports.onCreateTimelineTest = functions.firestore
.document("/timelineTest/{docId}")
.onCreate(async (snapshot, context) => {
const timeNow =new Date();
const db = admin.firestore();
return db.collection("timeline")
.get()
.then((timelineQuerySnapshot) => {
timelineQuerySnapshot.forEach(async(timelineQuerySnapshot) => {
console.log("all the documnets inside timeline are", timelineQuerySnapshot.id);
await db.collection("timeline")
.doc(timelineQuerySnapshot.id)
.collection("publisherId")
.get()
.then((publisherSnapshot)=>{
publisherSnapshot.forEach(async(publisherSnapshot)=>{
console.log("all the documnets inside timeline are", publisherSnapshot.id);
await db.collection("timeline")
.doc(timelineQuerySnapshot.id)
.collection("publisherId")
.doc(publisherSnapshot.id)
.collection("posts")
.where('uploadTime', '<=', timeNow)
.get()
.then((postSnap)=>{
postSnap.forEach(async(postSnap)=>{
console.log("all the documnets inside timeline are", postSnap.id);
return db.collection("timeline")
.doc(timelineQuerySnapshot.id)
.collection("publisherId")
.doc(publisherSnapshot.id)
.collection("posts")
.doc(postSnap.id)
.set({
'name': 'madhav'
}).catch((err)=>{
console.log('Error getting documents', err);
return Promise.reject(err);
});
});
return null
}).catch((err) => {
console.log('Error getting documents', err);
return Promise.reject(err);
});
});
return null
}).catch((err) => {
console.log('Error getting documents', err);
return Promise.reject(err);
});
});
return null
}).catch((err) => {
console.log('Error getting documents', err);
return Promise.reject(err);
});
});
這些功能在模擬器中運行良好,部署后,狀態為“ok”。 但是當我檢查 firestore 時,我發現沒有發生任何變化。 它仍然是一樣的。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.