【发布时间】:2020-07-23 15:25:12
【问题描述】:
我有以下 https 可调用云功能,可导入备份中找到的所有文档。
const client = await auth.getClient();
const path = `${timestamp}`;
const projectId = await auth.getProjectId();
// we change the action for importDocuments
const url = `https://firestore.googleapis.com/v1/projects/${projectId}/databases/(default):importDocuments`;
const backup_route = `gs://${BUCKET_NAME}/${path}`;
return client.request({
url,
method: 'POST',
data: {
inputUriPrefix: backup_route,
}
}).then(async (res) => {
console.log(`Backup restored from folder ${backup_route}`);
return Promise.resolve(true);
}).catch(async (e) => {
return Promise.reject(new functions.https.HttpsError('internal', e.message));
})
问题是在成功开始导入操作后,promise 解决了。但它不会等到导入完成。
我阅读了以下有关导入和长时间运行操作的文档,但没有找到我要查找的内容。 https://firebase.google.com/docs/firestore/reference/rest/v1/projects.databases/importDocuments https://firebase.google.com/docs/firestore/reference/rest/Shared.Types/Operation
【问题讨论】:
标签: javascript asynchronous google-cloud-firestore google-cloud-functions