草庐IT

Firebase2

全部标签

javascript - 有什么办法可以禁用所有 firebase 日志记录到控制台吗?

我已经为我的Firebase安全规则创建了一些单元测试。此测试的一部分是尝试进行非法操作并断言它们失败。我的问题与噪音有关;当我使用nodeunit运行测试时,firebase客户端会吐出几个类似于此的日志:FIREBASEWARNING:setat/userfailed:permission_denied我不希望在故意进行非法操作时出现此输出,因为它只会导致噪音和困惑。 最佳答案 现在有一个选项可以在全局firebase对象上设置日志级别:importfirebasefrom'firebase/app';firebase.setL

javascript - 在 firebase 中,为什么事务不像在 admin api 中那样在云函数中工作?

我有现有的管理api代码,为了测试目的我已经将其简化为这个代码(这有效):admin.database().ref('/dropbox').on('child_added',function(childSnap){letitem,itemRef=childSnap.ref;console.log(`Item:${JSON.stringify(childSnap.val())}at${childSnap.key}`);console.log(`Itemref:${itemRef.toString()}`);itemRef.transaction(function(value){conso

javascript - 'child_added' 和 'value' firebase 之间的区别?

在firebase中返回数据时,我发现child_added和value之间存在一点点差异。使用value我可以测试看看snapshot.val()是否返回了一些东西或者没有像这样使用它:获取数据:ref.orderByChild('appUserName').equalTo(issuer).once('value').then(function(snapshot){varvalue=snapshot.val();if(value){//HasValue...}else{//HasNoValue...}数据结构:AppUsers--234jl23jl4kj23--data--//..d

javascript - iPad 的 Safari 上的 Firebase;找不到变量 : Notification

我使用Firebase的云消息传递,但它不适用于iPad和iPhone。这是我能用它做的最简单的用法。我刚刚完成了所有关于异地通知的教程,但我直接在Firebase的脚本中得到了这个错误. 最佳答案 iOS不支持通知APIhttps://caniuse.com/#search=Notification我创建了一个函数,让您知道用户的浏览器是否支持它。constisSupported=()=>'Notification'inwindow&&'serviceWorker'innavigator&&'PushManager'inwindo

javascript - 如何在 firebase 云函数中使用 javascript setTimeout 函数

我正在尝试为firebase创建一个云函数,它根据延迟值删除用户并在延迟数之后插入。exports.delayqueue=functions.database.ref('/queues/{queueid}/members/{memberid}').onWrite(event=>{varmembers=event.data.ref.parent;varuser=event.data;varqueueid=members.parent;varuserid=event.params.memberid;vardelayfor=user.child('delay').val();varname=

javascript - Firebase:连接表

假设数据是这样的post:{authorId:'123AA',title:'firstPost',body:'yay'}author:{uid:'123AA',displayName:'Richard'email:'im@richard.com'}我想渲染一个带有作者姓名的帖子:{post.title}{post.body}{post.author.displayName}//problem获取的帖子项目仅包含作者的uid,但我需要作者的displayName。检索帖子时如何填充作者字段?这是我现在用来获取帖子的方法:constpostsRef=firebase.database().

javascript - Firebase .then 与 .on ('value' )

我试图让.then()与.on()一起工作,但它只与.once()一起工作.我得到playersRef.on(...).thenisnotafunction,当用on()尝试它时所以我现在拥有的是:letnodesRef=Firebase.database().ref('players')letanswers={}playersRef.on('value',(playersSnapshot)=>{playersRef.once('value').then((playersSnapshot)=>{playersSnapshot.forEach((playerSnapshot)=>{let

javascript - Angular 2 - Firebase 在页面刷新时保持登录状态

所以我真的很接近解决这个问题了。基本上,我有登录工作,我有代码设置来监视onAuthStateChanged,但问题是当我刷新页面时,即使用户当前已登录,它仍然重定向到/login页面因为我已经设置了authguard,检查用户是否登录。我有一个身份验证服务设置,可以执行所有身份验证检查。在我的auth服务构造函数中,这是我设置onAuthStateChanged代码的地方:constructor(privateauth:AngularFireAuth,privaterouter:Router,privatedb:AngularFireDatabase,){firebase.auth(

javascript - 如何从 Firebase Cloud Function 在 Google Pub/Sub 中发布消息?

我编写了一个函数来接收http请求并发送电子邮件。但是,我想接收一个http请求并发送一个pub消息。问题是文档不清楚。我该怎么做?这是我的实际代码。exports.weeklyEmail=functions.https.onRequest((req,res)=>{constemail='****@gmail.com'console.log('Sendinge-mail')constmailOptions={to:email,from:'****@alunos.utfpr.edu.br',subject:'Teste',text:'Conteudodoemail'}mailTransp

javascript - 抛出新功能。Firebase 云功能上的 https.HttpsError 被客户端拒绝为内部错误

我将以下CloudFunction部署到我的Firebase项目中:exports.createCredentials=functions.https.onCall((data,context)=>{if(!context.auth)thrownewfunctions.https.HttpsError('failed-auth','Youmustbeauthenticatedtocallthisfunction')const{email,password}=data;if(!(typeofemail==='string'))thrownewfunctions.https.HttpsEr