【问题标题】:How get last value of MongoDB property?如何获取 MongoDB 属性的最后一个值?
【发布时间】:2019-03-05 17:36:03
【问题描述】:

我正在尝试恢复已更改的 MongoDB 集合上的数据。

I.e. - property: false -> true,我没有整个收藏的备份。

有什么方法可以知道$set 操作之前的最后一个属性值是多少?喜欢对数据的操作历史记录?

它也可以基于时间戳。

示例:集合名称Users

更改前:

{name:"xxxx1", address:"yyyy1", test:false}
{name:"xxxx2", address:"yyyy2", test:true}
{name:"xxxx3", address:"yyyy3", test:false}
{name:"xxxx4", address:"yyyy4", test:true}

改动后:

{name:"xxxx1", address:"yyyy1", test:true}
{name:"xxxx2", address:"yyyy2", test:true}
{name:"xxxx3", address:"yyyy3", test:true}
{name:"xxxx4", address:"yyyy4", test:true}

我想知道所有值为test :false的实体:

{name:"xxxx1", address:"yyyy1", test:false}
{name:"xxxx3", address:"yyyy3", test:false}

有可能吗?

【问题讨论】:

    标签: mongodb mongoose mongodb-query mongoid


    【解决方案1】:

    除非您在此更新操作之前在您的收藏中安装了一些版本控制插件,否则无法提取更改。但是,您可能想查看oplog,它是一个封顶集合,用于存储对 MongoDB 数据库的逻辑写入的有序历史记录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2011-12-13
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多