无法部署 Firebase 功能 [英] Unable to deploy firebase function

查看:35
本文介绍了无法部署 Firebase 功能的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Node.js 命令提示符只是忽略了这个函数,而其他函数正在部署,我也没有收到任何错误.

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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆