Firebase 函数 V2:内存配置

问题描述 投票:0回答:1

如何在firestore触发云功能上设置选项

{memory: "1GiB"}

我在文档中找不到它:https://firebase.google.com/docs/functions/2nd-gen-upgrade

有一个 https 函数的示例,但 onDocumentCreated() 等似乎有不同的语法。

export const statisticsDataCreated = onDocumentCreated("statistics/data", async (event) => {
  /** Do things **/
});

你找到实现它的方法了吗?

firebase syntax google-cloud-functions
1个回答
0
投票

据我在此处的文档中看到(https://firebase.google.com/docs/functions/manage-functions?gen=2nd&hl=it#set_timeout_and_memory_allocation

选项可以作为回调函数本身之前的第一个参数传递:

exports.convertLargeFile = onObjectFinalized({
  timeoutSeconds: 300,
  memory: "1GiB",
}, (event) => {
  // Do some complicated things that take a lot of memory and time
});

虽然没有关于 onDocumentCreated 触发器的具体示例,但我建议您像这样使用它:

export const statisticsDataCreated = onDocumentCreated({memory: "1GiB"}, "statistics/data", async (event) => {
  /** Do things **/
});
© www.soinside.com 2019 - 2024. All rights reserved.