我试着做关于Google功能的第一个项目。我尝试了google提供的代码:
const functions = require("firebase-functions");
const admin = require("firebase-admin");
admin.initializeApp();
// Take the text parameter passed to this HTTP endpoint and insert it into
// Cloud Firestore under the path /messages/:documentId/
我在我的firebase云函数文件中创建了以下函数:
function whatsMyName(name) {
return "your name is " + name
}
当我在命令行中运行以下命令时,将部署该函数:
firebase deploy --only functions
但是,这就部署了我所有的功能。我只想部署whatsMyName函数。通常,如果我有一个导出的函数,如下所示:
exports.someExportedFunction = functions.https.onRequest((req, res) => {
// do some
我有一个Firebase云函数项目,我最近更新了所有的functions.https.onRequest,以通过Express运行来创建REST API服务。API工作得很好。但当我尝试部署该项目时,以前的Firebase数据库触发器都不再部署(例如: CalculateMyStats触发器运行良好,但已从我的云函数列表中删除)。现在只部署了rest函数。在同一个项目中可以有Rest API和触发器吗? index.ts import * as admin from 'firebase-admin';
import * as functions from 'fireb
我有一个firebase函数,应该每1小时运行一次,但只运行X次。我是这样安排的:
functions.pubsub.schedule('every 1 hour').onRun((context) => {
let counter = // read last counter value from db
counter++;
if(counter === X)
return;
// save counter in db
// my job
}
但这种方法并不是最优的,因为调度程序始终处于活动状态,即使不需要它也是
在Firebase如此多产的情况下,我有点惊讶地发现,我似乎找不到太多关于如何查询一组文档(其中ID未知)的集合,然后根据每个文档的属性执行一些逻辑的文档。
在我的特定示例中,我所要做的就是根据收费日期是否已过来查询未完成付款的集合,然后使用Stripe处理该收费。到目前为止,我还没有幸运地运行这个函数,我得到了这个错误:
TypeError: functions.firestore.collection is not a function
at exports.chargePendingStripeAccounts.functions.pubsub.schedule.onRun (/
我是Node的新手,他们试图创建一个将fr翻译成en的应用程序。当我在本地节点服务或firebase服务中使用它时,我的代码工作得很好,但是当我将它部署到Firebase函数时,它没有工作。
此外,Firebase部署运行但没有按预期更新google或单词not翻译,它显示"Pls等待“,但没有更新它任何帮助将不胜感激。
错误: /user_code/node_modules/google-translate-api/node_modules/google-translate-token/index.js:103:25 at at process._tickDomainCallbac
在我将firebase-admin和firebase-function更新到它们的最新版本(分别是8.0.0的8.12.1和3.1.0的3.6.1 )之后,在发送响应后向Firestore查询集合突然停止工作,所以我的代码基本上是这样的:
export const saveData = functions.https.onRequest(async (req, res) => {
// Doing some stuff here...
res.send({data: cards});
// Some other logic I need to perform here
我给我的用户一个选项“一周中的哪一天.”用户选择一周中的一天,我希望Firebase函数在用户选定的一天每周启动一次。
但是,我似乎不能将任何变量数据输入Firebase函数调度功能中。
我可以跑..。
exports.scheduledFunction = functions.pubsub.schedule('every 5 minutes').onRun((context) => {
console.log('This will be run every 5 minutes!');
});
但我似乎不能把“每5分钟”作为一个变量。
我可以