使用云功能,我想在午夜删除某些文档(我使用的是pubsub)。查询文档后如何删除?
export const taskDeletion = functions.pubsub.schedule('0 0 * * *')
.onRun((context) => {
const query = db.collection('tasks')
.where('dailyTask', '==', false)
.where('completed', '==', true);
const tasks = query.get();
});
使用对文档的引用并删除它们
// using an async function
const tasks = await query.get();
const del_ops = tasks.docs.map(doc => doc.ref.delete())
await Promise.all(del_ops)
//continue