javascript - 通过实时数据库 ServerValue 递增崩溃的云函数
问题描述
我是 Firebase 实时数据库的新手,但到目前为止,我已经使用 Firestore 几个月了。我在下面编写了一个云函数,它尝试使用 ServerValue 功能增加实时数据库中特定记录的访问计数。但它与 Firebase 日志一起崩溃
8:01:29.257 am incrCountByRTDB Function execution started
8:01:29.257 am incrCountByRTDB Billing account not configured. External network is not accessible and quotas are severely limited. Configure billing account to remove these restrictions
8:01:29.280 am incrCountByRTDB incrPersonAccessCountBy1
8:01:29.862 am incrCountByRTDB Function execution took 605 ms, finished with status: 'crash'
代码片段
const admin = require('firebase-admin');
const functions = require('firebase-functions');
admin.initializeApp();
exports.incrCountByRTDB = functions.https.onRequest((req, res) => {
console.log("incrPersonAccessCountBy1");
admin.database().ref('Persons').child('mur_123').child('accessCount')
.set(admin.database.ServerValue.increment(1))
.then(function() {
console.log('Increment succeeded');
return res.status(200).send("Successfully incremented the accesscount");
}).catch(function(error) {
console.log('Increment failed', error);
return res.status(200).send("Increment failed");
})
});
exports.createPersonsCollection = functions.https.onRequest((req, res) => {
admin.database().ref("Persons").child('mur_123').set({
name: 'murali',
accessCount: 0
}).then(function(){
return res.status(200).send("Successfully created the persons collection");
}).catch(function (ex){
console.log("Error", ex);
return res.status(500).send("Creation failed");
})
});
如果我遗漏了什么,请告诉我并帮助我解决这个问题。
谢谢穆拉利
解决方案
推荐阅读
- excel - 如何将 2 列与其他 2 列匹配
- javascript - 如何从 Javascript 中的 GWT 代码访问函数/变量?
- javascript - scrollIntoView onClick reactjs
- r - 将 MIN 和 MAX 组合成 R 中的 rowise 函数
- sql - 如何对字段求和
- javascript - Javascript 了解 PHP 何时改变了某些东西
- javascript - 使用 reactjs 进行服务器端渲染
- html - 表单无法包含语义 UI CDN
- angular - 我不能在 angular 上使用 http get 的结果
- javascript - 根据下拉列表索引项JS更改var