Tag: firebase

将巨大的Firebase数据库更新为交易

我正在使用Firebase数据库为iOS应用程序和维护巨大的数据库。 对于一些事件,我使用云function来同时更新几个兄弟节点作为事务。 但是,一些节点包含巨大的子节点(可能是一百万)。 在云function方面是否扩大了大量logging?

Firebase的云端function – 移除最老的孩子

我有一个onWrite云function设置为侦听当用户更新的东西。 我想删除最大的孩子,如果有超过3,这是我在: exports.removeOld = functions.database.ref('/users/{uid}/media').onWrite(event => { const uid = event.params.uid if(event.data.numChildren() > 3) { //Remove Oldest child… } }) 每个孩子都有一个"timestamp"键。 { "users" : { "jKAWX7v9dSOsJtatyHHXPQ3MO193" : { "media" : { "-Kq2_NvqCXCg_ogVRvA" : { "date" : 1.501151203274347E9, "title" : "Something…" }, "-Kq2_V3t_kws3vlAt6B" : { "date" : 1.501151232526373E9, "title" : "Hello World.." } "-Kq2_V3t_kws3B6B" : { […]

电子Firebase:FIREBASE警告:提供的身份validation凭据无效

我已经创build了使用Firebase身份validation和数据库的electron应用程序。 应用程序使用signInWithCustomToken和来自远程服务器的令牌。 在我的工作机器上(macOS)它按预期工作。 但是,当我克隆我的回购家用机器(Windows),我收到 FIREBASE WARNING: Provided authentication credentials are invalid. This usually indicates your FirebaseApp instance was not initialized correctly. Make sure your apiKey and databaseURL match the values provided for your app at https://console.firebase.google.com/ 正如我在这里发现与firebase-admin相同的问题错误。 但是我正在使用客户端库。 另外我误解了它如何依赖于它运行的机器? 我使用与webpack打包在一起的npm包webpack firebase 4.1.5到客户端脚本中 初始化: const firebaseConf = { apiKey: '<api_key>', authDomain: '<domain>.firebaseapp.com', databaseURL: 'https://<database>.firebaseio.com', projectId: '<project_id>', […]

尝试通过Firebase云端function发送通知(Android)后出现错误

我是Firebase和nodejs的新手。 我正尝试使用Firebase云端函数从一台设备向另一台设备发送通知。 这是发送通知的node.js代码: var functions = require('firebase-functions'); var admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); exports.sendNotification = functions.database.ref('/sendNotification/{notificationId}') .onWrite(event => { var regToken="fYRweeL8cic:APA91bH6Q_gyKKrLL…"; // Grab the current value of what was written to the Realtime Database. var eventSnapshot = event.data; var payload = { data: { title: eventSnapshot.child("title").val() } }; // Set the message as high priority and […]

Firebase RangeError:检索数据时string的长度无效

我正在使用Firebase /数据库Node.js / Admin。 我试图找回超过100K的孩子(并在客户端工作)。 我得到了以下错误(加载很长时间后): /node_modules/firebase-admin/lib/database/database.js:161 function Sf(a,b){a.frames.push(b);if(a.frames.length==a.De){var c=a.frames.join("");a.frames=null;c=eb(c);a.Xf(c)}}h.send=function(a){Rf(this);a=A(a);this.ob+=a.length;Gf(this.Ua,"bytes_sent",a.length);a=pc(a,16384);1<a.length&&Tf(this,String(a.length));for(var b=0;b<a.length;b++)Tf(this,a[b])};h.Qc=function(){this.yb=!0;this.wc&&(clearInterval(this.wc),this.wc=null);this.Ha&&(this.Ha.close(),this.Ha=null)}; RangeError: Invalid string length at Array.join (native) at Sf (/node_modules/firebase-admin/lib/database/database.js:161:76) at Client.Ha.onmessage (/node_modules/firebase-admin/lib/database/database.js:159:289) 我用下面的代码与Node.js运行此: var databaseRef = defaultApp.database().ref('a_root_node'); var usersRef = databaseRef.child('users') usersRef.once('value').then(snapshot => { res.status(200).send(snapshot.val()) }) 我也尝试将其作为Firebasefunction运行,并增加了内存限制,但错误是一样的。

在Firebase云端函数中使用toLocaleString格式化货币值

我正在尝试根据node.js中的toLocaleString为firebase云function设置一个double值。 这是我使用的代码: PriceFormated = Price.toFixed(2).toLocaleString("de-DE", {style: "currency", currency: CurrencySymbol}); console.log('Price:',PriceFormated) 其结果是:“价格:1984.00” 但应该是:“价格:1.984,00” 作为参考,请查看: http : //droidscript.org/javascript/Global_Objects/Number/toLocaleString().html或https://www.jsman.net/manual/Standard-Global-Objects/Number/toLocaleString 代码中是否有错误,或firebase云function是否按预期工作?

Firebase手电筒 – Bonsai-ElasticSearch API调用来执行search

我刚刚实施了Firebase Flashlight和Bonsai ElasticSearch ,以便能够在我的iOS应用程序中对我的数据执行预先查询。 我已经完成了以下教程: 使用Node.JS的iOS Firebase Flashlight / ElasticSearch Heroku安装程序 我遇到的问题是,最后,在Heroku上运行Node.js应用程序,我不知道如何继续和使用它来执行我的iOS应用程序中的search。 从我的理解,到目前为止,我必须执行一个API调用我的Bonsai-ElasticSearch ,从那里它将使用Flashlight应用程序,以便返回我想要的结果。 问题是我不知道如何做到这一点,你可以说,我是使用Flashlight或Bonsai-ElasticSearch 。 如果您对我如何做到这一点有什么build议,或者至less指出我的方向是正确的,那将是惊人的。 谢谢

Firebase客户端不接收邮件

我有以下的Node.js script : var registrationToken = "Long Token"; var serviceAccount = require("./config/ServiceAccount.json"); var payload = { data: { score: "850", time: "2:45" } }; admin.initializeApp({ credential: admin.credential.cert(serviceAccount), databaseURL: fireBaseConfig.databaseURL }); admin.messaging().sendToDevice(registrationToken, payload) .then(function(response) { // See the MessagingDevicesResponse reference documentation for // the contents of response. console.log("Successfully sent message:", response); }) .catch(function(error) { console.log("Error sending […]

从Firebasefunction访问Google Site Verification API

我正在尝试使用Node.js的Firebase函数使用Google Site Verification API 。 Github的google-api-nodejs-client存储库中提供的READMEbuild议使用默认的应用程序方法,而不是手动创buildOAuth2客户端,JWT客户端或计算客户端。 我写了下面的例子,我尝试在本地(模拟function环境)上运行,并在Firebasefunction上远程运行: const google = require('googleapis'); google.auth.getApplicationDefault(function (err, authClient, projectId) { if (err) { console.log('Authentication failed because of ', err); return; } if (authClient.createScopedRequired && authClient.createScopedRequired()) { authClient = authClient.createScoped([ 'https://www.googleapis.com/auth/siteverification' ]); } const siteVerification = google.siteVerification({ version: 'v1', auth: authClient }); siteVerification.webResource.get({ id: 'test.com' }, {}, function (err, data) […]

试图访问实时数据库时,Firebase Node.jspipe理SDK超时

使用带有Firebase函数的Node.js admin SDK每当我尝试访问实时数据库时,都会收到一个超时值。 只有在本地testing函数( firebase serve –only functions,hosting仅适用firebase serve –only functions,hosting )以及使用functions.config().firebase firebase serve –only functions,hosting初始化默认应用程序时才会发生这种情况。 这是一个刚刚发生在几天前的新行为。 但是,如果我尝试使用serviceAccount.json文件初始化默认应用程序,则一切正常。 我正在使用firebase-admin版本4.2.1和firebase firebase-functions版本0.5.9 。 我写了一个简单的http triggered函数,由于超时而失败: const functions = require('firebase-functions'); const admin = require('firebase-admin'); admin.initializeApp(functions.config().firebase); const db = admin.database(); exports.testDbConnection = functions.https.onRequest((req, res) => { return admin.database().ref().once('value') .then(function(snapshot) { res.json(snapshot); }).catch(function(error) { res.json(error); }); });