Tag: firebase

获取Firebase参考的path

如何获取Firebasepath(没有主机名部分的位置string,例如"users/user1" )给出了Firebase引用? 我找不到文档,试图search,但没有运气。 现在我确实喜欢Node.js中给出的Firebase引用ref : var url = require('url'); // standard Node.js 'url' module. var location = url.parse(ref.toString()).pathname; 这是正确的方法还是存在一个更可靠的方法? PS。 我看到ref.path.o是包含可以构buildpath的string的数组,但我认为它不在公共API上,并可能会改变?

使用新的Firebase的Nodejs应用程序不会检索数据库项目

我是新的nodejs,但已经在Firebase版本3.0.2中有一个工作的js客户端程序。 事实certificate,我需要一个服务器来做一些简单的事情,在js客户端中是不可能的。 当我在nodejs中尝试这个基本的东西时,什么都不会发生 – 数据库中的数据永远不会被检索到,并且节点服务器程序继续运行而没有错误。 服务器程序(server.js)如下所示: var firebase = require("firebase"); var myApp =firebase.initializeApp({ serviceAccount: "xxx/xxx.json", databaseURL: "https://xxx.firebaseio.com" }); firebase.database().ref().on('value', function(snapshot) { console.log("urls value changed"); // NEVER GETS HERE console.log(snapshot.val()); }); 数据库加载数据,这是试图查看根。 当我通过控制台添加项目到数据库,仍然没有任何反应。 更具体的ref()值不起作用。 我正在使用节点版本v4.4.4。 程序在命令行(在MBP / OSX上)用“node server.js”调用。 我花了几个小时试图弄清楚我做错了什么 – 可能是愚蠢的! 提前感谢您的帮助。

firebase.auth()。createUserWithEmailAndPassword Undefined不是一个函数

我正在关注用户pipe理的Firebase文档 var firebase = require('firebase'); // Initialize Firebase firebase.initializeApp({ serviceAccount: "./<mysecreturledittedout>.json", databaseURL: "https://<mydatabaseurljusttobesafe>.firebaseio.com" }); router.get('/create', function(req, res){ var email = req.email; var password = req.password; firebase.auth().createUserWithEmailAndPassword(email, password).catch(function(err){ // LINE 27 CRASH var errorCode = err.code; var errorMessage = error.message; console.log("ERROR"); console.log(errorCode, errorMessage); }); }); 我得到以下错误 undefined is not a function TypeError: undefined is not a […]

在Firebase中部署function时获取Firebase未find错误

我正在尝试在firebase中托pipe一个应用程序,它给了我错误信息 Error: Error parsing triggers: Cannot find module 'firebase' Try running "npm install" in your functions directory before deploying. 我已经多次执行npm install命令,但没有新的东西。 请帮忙

Firebase .orderByChild()。equalTo()。once()。then()当孩子不存在时承诺

我的API /auth/login端点需要像这样的req.body : { "email": "jacob@gmail.com", "password": "supersecretpassword" } 在端点上,我参考了我的Firebase数据库( https://jacob.firebaseio.com/users )。 我search数据,当我find一个与req.body.email相匹配的req.body.email ,我将密码与数据库中存储的密码进行比较。 我遵循这个Firebase博客文章中概述的承诺结构。 router.post('/login', function(req, res) { const ref = db.ref('/users'); ref.orderByChild('email') .equalTo(req.body.email) .once('child_added') .then(function (snapshot) { return snapshot.val(); }) .then(function (usr) { // Do my thing, throw any errors that come up }) .catch(function (err) { // Handle my errors with grace […]

SyntaxError:意外的标记'const' – 尽pipe我取代了const

我试图导出我的firebase应用程序,所以我可以称之为摩卡testing规范,以及我试图testing的源代码。 我的摩卡testing规格如下所示: import Vue from 'vue' import Edit from '@/components/Edit' import filedata from '../../../static/filedata.js' import submitFile from '../../../helpers/submitFile.js' import firebaseapp from '../../../src/db.js' var db = firebaseapp.database() var storage = firebaseapp.storage() describe('Edit.vue', () => { it('should let me add files without choosing a category', () => { // add files to appear on the homepage var […]

使用Node.JS的iOS Firebase Flashlight / ElasticSearch Heroku安装程序

我正在使用Firebase后端在Swift中构build一个iOS应用程序。 我需要高级search选项为我的应用程序。 我被告知我应该通过这个github链接使用Flashlight / ElasticSearch https://github.com/firebase/flashlight 假设我的应用程序的名称是SneakerSearch和我的 Firebase Project_ID is- sneakersearch-az12 Firebase Web_API_Key is- abc123XYZ000… Firebase App_Url is- gs://sneakersearch-az12.appspot.com 我需要一些build议与设置这个步骤,因为我是新的Heroku和Node.js。 我以前从来没有学过,但我已经安装了Heroku工具带,并完成“sudo gem heroku安装”。 我列出了Github的方向/步骤和我为每个方向所采取的步骤。 我需要指导帮助:1,4,5,6,9,10,12和15。 1.Install and run ElasticSearch or add Bonsai service via Heroku 我在Heroku做了一个帐户。 1.问题:我是否需要创build应用程序的名称,并在设置Heroku帐户后进行部署,还是应该等到步骤#9? 2.git clone https://github.com/firebase/flashlight 2.我把上面的东西克隆到我的iOS应用程序的项目文件夹中 3.npm install 3.提示我首先运行“npm init”,然后运行“npm install” 4. edit config.js (see comments at the top, you […]

Firebase云端function总是超时

我正在探索Firebase云计算function,并试图通过http请求发送通知。 问题是,即使我设法发送通知,请求总是超时。 这是我的脚本 const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.friendRequestNotification = functions.https.onRequest((req, res) => { const senderId = req.query.senderId; const recipientId = req.query.recipientId; const getRecipientPromise = admin.database().ref(`/players/${recipientId}`).once('value'); const getSenderPromise = admin.database().ref(`/players/${senderId}`).once('value'); return Promise.all([getRecipientPromise, getSenderPromise]).then(results => { const recipient = results[0]; const sender = results[1]; const recipientToken = recipient.child("notificationsInfo/fcmToken").val(); const notificationAuthorization = recipient.child("notificationsInfo/wantsToReceiveNotifications").val(); […]

Firebase云端函数:增量计数器

使用事务处理实时数据库触发器增加计数器是否可以接受? exports.incPostCount = functions.database.ref('/threadsMeta/{threadId}/posts') .onWrite(event => { admin.database().ref('/analytics/postCount') .transaction(count => { if (count === null) { return count = 1 } else { return count + 1 } }) });

Firebase的云端function:pipe理员与根查找

掌握Firebase和JavaScript以编码云function; 但我想我正在寻找是否有人可以解释使用以下查找和/或写入云function的优点和缺点?! 使用admin.database().ref() VS root.child() 我自己一直在使用admin.database.ref() ,但我需要? 使用root.child()而不是同样好?