-1

I'm planning on building site that allows users to add, edit and delete records depending on their status, not that dissimilar from Stack Overflow. Any user should be able to edit records like a wiki, but to avoid sabotage all revisions must be saved so that we can revert back if need be.

I imagine there are several ways you could do this. How do sites like Wikipedia and Stack Overflow manage this type of data?

PS. I am using MongoDB for data persistence.

4

1 回答 1

3

你有两个正交的选择。

贮存

  1. 将历史记录保存在同一个文档中,保存在字段名称versions(或其他)中。

  2. 将更改保存到单独的集合以保持原始文档的清洁。

格式

  1. 逐字保存原始版本。这有助于回滚(只需获取上一个版本并覆盖当前版本)。
  2. 仅存储修改过的字段,这将为您节省一些空间(添加/删除字段时要小心)。

    2.1。为了进一步节省空间,您可以存储字符串值的差异。

于 2012-05-27T09:26:10.243 回答