在Firebase上运行总计(Running total on Firebase)

编程入门 行业动态 更新时间:2024-10-25 00:30:58
Firebase上运行总计(Running total on Firebase)

我想知道如何使用Firebase进行运行总计。 我目前正在开发一个跟踪用户活动的平台,并为完成验证事件提供积分。 我目前正在使用Firebase作为后端。 我选择Firebase的原因是因为方便。 我还没有开始编写提供分数的部分,但我的流程概述如下

用户验证活动 Validator(具有更多权限的另一个用户)验证User已完成的活动。 已完成事件的点值将添加到用户的总点数中。

困扰我的是第三步。 是否可以在不引入另一种后端技术的情况下完成第三步? 目前我用来创建活动的所有用户都是firebase和app。

目前我认为我应该让Validator增加用户分数,但这意味着让一个用户直接访问另一个用户的属性。 那被认为是不好的做法吗? 有没有办法让Firebase简单地添加两个值,还是我必须引入第三个技术?

I am wondering how to go about making a running total using Firebase. I am currently working on a platform that keeps track of user activities and gives them points for completing validated events. I am currently using Firebase for the back end. The reason why I chose Firebase is because of convenience really. I haven't started coding the part that gives points yet but I have the process outlined as followed

User validates activity Validator (another user with more authority ) validates that User completed activity. The point value of the completed event is added to the user's total points.

What is bothering me is the third step. Is it possible to do that third step without introducing another piece of backend technology? At present all I'm using to create the activities and users is firebase and the app.

At present I am thinking that I should have the Validator increment the user score however that would mean giving one user direct access to a property of another. Is that considered bad practice? Is there a way to have a Firebase simply add two values or do I have to introduce a third piece of tech?

最满意答案

一种可能的解决方案是在Firebase实时数据库中创建一个数据库目录,该目录存储将为每个活动获得的点。 活动完成后,您将获取Firebase数据库中用户的目录,获取其点的值,添加点的值,然后将新值发送回数据库。

这将要求管理员用户访问其他用户点,如果处理私人交易(如信用卡或金钱)(这对Firebase来说可能不是一个好主意),这是不好的做法。 如果你正在处理没有任何实际价值的东西,那就没关系。

One potential solution is to create a database directory in the Firebase realtime database that stores the points that will be gained for each activity. When the activity is completed, you get the directory for the user in your Firebase database, get a value for their points, add to the value for the points, and then send the new value back to the database.

This would require giving the admin user access to the other users points, which is bad practice if dealing with private transactions such as credit cards or money (which probably isn't a good idea with Firebase anyway). If you are dealing with something without any actual value it is okay.

更多推荐

本文发布于:2023-08-03 14:22:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1390757.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:Firebase   Running   total

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!