Mongodb 自动写入 capped 集合

发布于 2024-10-10 02:40:38 字数 183 浏览 0 评论 0原文

我需要管理每小时许多记录的获取。大约 1000000 条记录。我需要每秒获取每个主键的最后一个插入值。它与分片配合得很好。我正在考虑尝试使用 os capped 集合来仅获取每个主键的最后一条记录。为了做到这一点,我做了两个单独的插入,有没有办法,进入 mongodb ,制作某种触​​发器将插入到一个集合中传播到另一个集合?

I need to manage the acquisition of many record at hour. About 1000000 records. And I need to get every second the last insert value for every primary key. It works quit well with sharding. I was thinking to try the use os capped collection to get only the last record for every primary key. In order to do this, I made two separated insert, there is a way, into mongodb, to make some kind of trigger to propagate the insert into a collection to another collection?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

欢烬 2024-10-17 02:40:38

MongoDB 不支持触​​发器或类似行为。

做到这一点的唯一方法是在您的代码中实现它。因此,编写第一个条目的代码也应该编写第二个条目。

人们肯定要求触发器。如果您的解决方案需要它们,请对功能请求进行投票

MongoDB does not have any support for triggers or similar behavior.

The only way to do this is to make it happen in your code. So the code that writes the first entry should also write the second.

People have definitely requested triggers. If they are necessary for your solution, please cast a vote on the feature request.

‖放下 2024-10-17 02:40:38

我不同意“需要触发器”。大家,MongoDB 的创建速度非常快,并提供尽可能基本的功能。这是该解决方案的强大之处。

我认为这里最好的想法是在应用程序内部创建触发器作为数据访问层的一部分。

I disagree with "triggers is needed". People, MongoDB was created to be very fast and to provide as basic functionalities as can be. This is a power of this solution.

I think that here the best think is to create triggers inside Your application as a part of Data Access layer.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文