无法部署Firebase功能 [英] Unable to deploy firebase function
本文介绍了无法部署Firebase功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
var database = admin.database();
var postsRef = database.ref(/ posts);
postsRef.on('child_added',addOrUpdateIndexRecord);
函数addOrUpdateIndexRecord(dataSnapshot){
//获取Firebase对象
var firebaseObject = dataSnapshot.val();
//使用Firebase对象键指定Algolia的objectID
firebaseObject.objectID = dataSnapshot.key;
//添加或更新对象
index.saveObject(firebaseObject,function(err,content){
if(err){
throw err;
}
console.log('在Algolia中索引的Firebase对象,firebaseObject.objectID);
});
$ b $ div class =h2_lin>解决方案
如果是数据库触发函数,那么你使用的语法是不正确的。试试这样做:
$ b $ pre $ export $ export $ (event => {
//用触发
来做任何事情));
Node.js command prompt is simply ignoring this function, while the other functions are getting deployed, I am not getting any error either.
var database = admin.database();
var postsRef = database.ref("/posts");
postsRef.on('child_added', addOrUpdateIndexRecord);
function addOrUpdateIndexRecord(dataSnapshot) {
// Get Firebase object
var firebaseObject = dataSnapshot.val();
// Specify Algolia's objectID using the Firebase object key
firebaseObject.objectID = dataSnapshot.key;
// Add or update object
index.saveObject(firebaseObject, function(err, content) {
if (err) {
throw err;
}
console.log('Firebase object indexed in Algolia', firebaseObject.objectID);
});
}
解决方案
If it's a database trigger function, then the syntax you are using is not correct. Try doing this way:
exports.updateposts = functions.database.ref("posts/")
.onWrite(event => {
//Do whatever you want to do with trigger
});
这篇关于无法部署Firebase功能的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文