【问题标题】:Deploying changes only to Firebase helper functions仅将更改部署到 Firebase 辅助函数
【发布时间】:2021-01-19 01:16:48
【问题描述】:

在我的 firebase 函数文件中,我有两种类型的函数:

  1. 将由 Firestore 和 HTTPS 可调用函数触发的导出函数。
  2. 在导出函数中使用的辅助函数。

其中一些辅助函数用于多个导出函数,因此不能包含在导出函数中。

是否可以仅将更改部署到特定的辅助函数?我尝试了以下方法: firebase deploy --only functions:main.functionName 但是这不起作用。

我想导出我的所有函数不是一个好主意,以便在需要时可以单独更新它们,但我没有任何理由,这只是基于它没有在教程视频中完成和文档。

谢谢!

【问题讨论】:

  • 我编辑了我的答案以展示如何导出一个函数或将它们组合在一起

标签: node.js firebase google-cloud-functions


【解决方案1】:

如果您想将它们组合在一起,这应该可以工作

import * as functions from 'firebase-functions'    
const functionBuilder = functions.region(REGION)

export const helperFunctions = {
    // Add all helper functions here and deploy them all at once
    // Not sure if youre using onRequest or onCall etc
    functionOneName: functionBuilder.https.onRequest(functionOneImportedFunction),
    functionTwoName: functionBuilder.https.onRequest(functionTwoImportedFunction),
}

然后从命令行

firebase deploy --only functions:helperFunctions

对于单个函数

import * as functions from 'firebase-functions'    
const functionBuilder = functions.region(REGION)
export const functionName = functionBuilder.https.onRequest(functionOneImportedFunction)

然后从命令行

firebase deploy --only functions:functionName

【讨论】:

  • 谢谢@omeanwell,我会尽快进行测试,如果可行,请投票。抱歉延迟回复!
  • 别担心!如果对您有用,您可以将其标记为答案:)
  • 我遇到了同样的问题:我无法部署在导出的触发器函数中使用的辅助函数。在我的情况下,这些不是触发函数,只是可重用的 js 函数(这似乎也是 OP 的情况,因为触发函数是 OP 的第 1 项)。我无法完成这项工作,我怀疑这是因为它们不是触发函数。
猜你喜欢
  • 1970-01-01
  • 2022-09-29
  • 1970-01-01
  • 2020-05-30
  • 1970-01-01
  • 2020-01-03
  • 1970-01-01
  • 2017-10-05
  • 1970-01-01
相关资源
最近更新 更多