守则是:
const functions = require('firebase-functions'); // is installed automatically when you init the project
const { auth } = require('google-auth-library'); // is used to authenticate your request
async function exportDB () {
const admin = await auth.getClient({
scopes: [ // scopes required to make a request
'https://www.googleapis.com/auth/datastore',
'https://www.googleapis.com/auth/cloud-platform'
]
});
const projectId = await auth.getProjectId();
const url = `https://firestore.googleapis.com/v1beta1/projects/${projectId}/databases/(default):exportDocuments`;
return admin.request({
url,
method: 'post',
data: {
outputUriPrefix: 'gs://name-of-the-bucket-you-created-for-backups'
}
});
}
const = functions.pubsub.topic('YOUR_TOPIC_NAME_HERE').onPublish(exportDB);module.exports ={ backup };
当我通过以下方式部署时:
gcloud functions deploy backup --runtime nodejs8 --trigger-topic YOUR_TOPIC_NAME_HERE
我得到了错误:
错误:(gcloud.functions.deploy) OperationError: code=3,message=Function在加载用户代码时失败。错误信息:无法加载文件index.js中的代码。代码中有语法错误吗? 详细堆栈跟踪: TypeError:无法读取未定义属性的“用户”
这是谷歌图书馆的东西吗?
发布于 2019-09-06 12:36:00
我假设您正在尝试部署由HTTP请求触发的GCF功能,我建议您检查这个link1似乎是相同的用例,并且可以帮助您在GCF上使用和node.js
https://stackoverflow.com/questions/57825693
复制