【发布时间】:2020-12-21 06:34:20
【问题描述】:
我想从 firestore 中删除一个文档以及该文档内的所有集合。为此,我使用以节点 8 作为引擎的云功能,它实际上已部署。但有些事情没有按预期工作。
这是我的路线 / postsCollection / user / user_posts_collection / 大文件
所以我想删除用户文档以及该文档中包含的所有内容 => user_posts_collection 及其文档
Node.js,云函数
exports.deleteUserPostsDocument = functions
.runWith({
timeoutSeconds: 540,
memory: '2GB'
})
.https.onCall(async(data, context) => {
const path = data.path;
await firebase_tools.firestore
.delete(path, {
project: process.env.GCLOUD_PROJECT,
recursive: true,
yes: true,
token: functions.config().fb.token
});
return {
path: path
};
});
Kotlin,调用函数
val path = "/posts/user"
val data = hashMapOf("path" to path)
var success = false
functions
.getHttpsCallable("deleteUserPostsDocument")
.call(data)
.continueWith {task ->
success = task.isSuccessful
}.await()
return success
代码与他们显示的here 完全相同,如果您只是管理员,我只是删除了要访问的代码。所以应该没有问题。
我按照 they indicated 的所有步骤进行操作,使用 firebase login、firebase login:cli 等。我可以看到该功能正在部署到我的 firebase 云功能
问题:我错过了什么?
【问题讨论】:
-
请注意 env.GCLOUD_PROJECT 已弃用,请改用 env.GCP_PROJECT。 cloud.google.com/functions/docs/…
标签: android firebase kotlin google-cloud-firestore google-cloud-functions