MongoDB - 从上限集合中捕获删除的对象
引用 关于 Capped Collections 的 MongoDB 文档:
一旦空间被充分利用, 新添加的对象将取代 集合中最旧的对象。
有什么方法可以在覆盖集合之前捕获“丢弃”的对象吗?我感兴趣的是实现一系列汇总集合。例如。
Hourly --> Daily --> Weekly --> Monthly etc.
因此,当一个对象从每小时集合中删除时,我想捕获它并将其聚合到每日集合中。
提前致谢。
//尼古拉斯
Quoting from the MongoDB docs on Capped Collections:
Once the space is fully utilized,
newly added objects will replace the
oldest objects in the collection.
Is there any way to capture a capped collection's "dropped" objects before they are overwritten ? What I am interested in doing is implementing a series of rollup collections. eg.
Hourly --> Daily --> Weekly --> Monthly etc.
so when an object is dropped from the Hourly collections, I want to capture it and aggregate it up to the Daily collection.
Thanks in advance.
//Nicholas
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您必须在代码中而不是在 MongoDB 中实现该功能。
我认为 Capped Collections 不是适合您的用例的正确解决方案。
您可以插入到一个上限集合中,同时插入到一个“正常”集合中,并将它们聚合为每小时/每天、每周、每月等......使用MapReduce。
You would have to implement that functionality in code rather than in MongoDB.
I don't think Capped Collections are the right solution for your use-case.
You could insert into a capped collection, and at the same time insert into a "normal" collection, and aggregate them into hourly / daily, weekly, monthly etc... using map reduce.
根据 MongoDB 开发人员的说法,您不能这样做:
http://groups.google.com/group/mongodb-user/browse_thread/thread/aec8d0c85f58d89e/d6701df083eb4679?fwc=1
正如 alex 所说,解决这个问题的一种方法是使用 MapReduce。另一种方法是每天有一个不同的集合,例如logs20110414,并让您的应用程序管理对适当集合的读/写。
As per the MongoDB developers, you can't do this:
http://groups.google.com/group/mongodb-user/browse_thread/thread/aec8d0c85f58d89e/d6701df083eb4679?fwc=1
As alex said, one way to solve this is to use MapReduce. Another way is to have a different collection e.g. per day, for example logs20110414 and have your application manage read/writes to the appropriate collection.