javascript - 无法从 Android Studio 部署到 Firebase Cloud Functions
问题描述
我最近根据此处的文档更新了新的云功能。
我已经对之前响应我的.onCreate()
方法的代码进行了所有更新。但是,现在当我调用 时firebase deploy --only functions
,我在 Android Studio 中的终端只是冻结了,我检查了我的 Firebase 控制台中的日志,发现没有执行任何操作。
下面是相关的代码,node.js 和 JavaScript:
const functions = require('firebase-functions');
const admin = require('firebase-admin');
admin.initializeApp();
exports.trackVote =
functions.firestore.document('Polls/{pollId}/responses/{userId}')
.onCreate(change, context => {
const data = change.after.data();
const answerSelected = data.answer;
const answerRef = admin.firestore().doc(`Polls/${event.params.pollId}/answers/${answerSelected}`);
const voteCountRef = admin.firestore.doc(`Polls/${event.params.pollId}/vote_count`);
return admin.firestore().runTransaction(t => {
return t.get(answerRef)
.then(doc => {
if (doc.data()) {
t.update(answerRef, { vote_count: doc.data().vote_count + 1 });
}
}
};
//do not add to Git
return admin.firestore().runTransaction(t => {
return t.get(voteCountRef)
.then(doc =>){
if (doc.data()){
t.update(voteCountRef, {vote_count:doc.data().vote_count+1});
}
}
};
});
编辑:错误终于出现了:
SyntaxError: missing ) after argument list
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:607:28)
at Object.Module._extensions..js (module.js:654:10)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at /usr/local/lib/node_modules/firebase-tools/lib/triggerParser.js:18:11
解决方案
推荐阅读
- php - 如何在数组php中使用规律性元素推送
- node.js - 使用 app.relaunch 后如何阻止 Electron 应用程序自行重启?
- css - 使用flex时有没有办法增加div的高度?
- html - 获取相对于 H1 文本保持在同一位置的图形
- python - Python os.enviro、parseargs 和 main 上的 Checkmarx OS_Access_Violation
- javascript - 如何根据 Promise 链中的阶段来区分错误的来源
- java - 如何将 LocalDate 转换为 ChronoZonedDateTime?
- .net - 在 X509Chain 中使用自定义根进行在线吊销检查
- javascript - 在 JS 中过滤二维数组
- oracle - 从 oracle 转换为 db2