Firebase:如何有效跟踪用户/记录更改历史记录 [英] Firebase: how to efficiently track user/record change history

查看:173
本文介绍了Firebase:如何有效跟踪用户/记录更改历史记录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

[关于SO的很多讨论,但是几乎所有都是关于SQL的,所以就我所知,很多问题对我的问题来说是N / A ]

我正在编写具有反应 / redux , code> firebase 后端,& AWS lambda 函数在需要时提供功能。

i'm writing a CRUD app with react/redux, a firebase backend, & AWS lambda functions where necessary.

我的用户会对查看更改内容和记录时间感兴趣,但是我正在努力寻求一种有效的方法。

My users will be interested in seeing what's been changed and when in their records, but I'm struggling with an efficient way to do this.

我目前的计划是维护带有 previousVal , changeDate userMakingChange Redux 有一些很棒的中间件,可以使它在客户端相当简单。

My current plan is to maintain a collection of "record updates" records with fields like previousVal, changeDate, and userMakingChange. Redux has some great middleware that would make this fairly straightforward in the client-side.

img是数据库我想到的架构。 Firebase强调非常平坦的数据结构,我希望按需按需加载修订历史记录,而与用户/记录分开,因此是修订历史记录的中间表。

the img is the database schema i had in mind. Firebase stresses very flat data structures, and I want revision histories to load on-demand, separate from their user/record, hence the intermediate tables of revision histories.

所以,我的问题:


  1. 修订历史记录系统如何处理迅速增长的存储需求?

  2. 是否有一种不太复杂的方法?我认为必须要有像这样的行业最佳实践。

推荐答案

如果您愿意放弃Firebase,则 Datomic 将非常适合您尝试做的事情。它使用Clojure持久数据结构中的结构共享技术创建有效的数据副本,这些副本与原始版本共享尽可能多的结构。

If you're happy to forego Firebase, then Datomic would be a perfect fit for what you're trying to do. It uses the structural sharing techniques from Clojure's persistent data structures to create efficient copies of data, which share as much structure as possible with the original versions.

回到过去的版本,我想说Datomic可能是行业标准解决方案。但是,这些技术并不是特定于Datomic的,通过一些工作,您也可以使用Firebase来实现它们。

As far as being able to revert to past versions goes, I'd say that Datomic is probably the industry standard solution. However, the techniques aren't specific to Datomic and with some work, you could implement them with Firebase too.

但是,就它的价值而言,我不会在您发现Firebase实例超出大小限制之前,您不应该去麻烦一下。相反,我建议采用绝对最简单的方法。

However, for what it's worth, I'd don't think it's worth going to the trouble until you find your Firebase instance is outgrowing the size limitations. Instead, I'd suggest going with the absolute simplest approach.

保持数据不变,并将每个实体视为值列表。每次要添加新修订时,请将其推到末尾。要还原,请从堆栈中弹出所需数量的值。编写一些像这样处理所有引用的Firebase包装器并不需要太多工作。

Keep your data flat and treat each entity as a list of values. Each time you want to add a new revision, push it onto the end. To revert, pop the required number of values off the stack. It wouldn't be too much work to write some Firebase wrappers which treated all references like this.

或者,如果您觉得雄心勃勃,可以尝试结合具有ClojureScript持久数据结构的数据脚本,然后将其序列化为JSON,然后将其存储在Firebase中,然后像使用Datomic一样使用它。

Alternatively, if you're feeling super ambitious you could try to combine datascript with ClojureScript's persistent data structures, then serialize them to JSON, then store them in Firebase, then use it as though it was like Datomic.

这篇关于Firebase:如何有效跟踪用户/记录更改历史记录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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