Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongodb automatically write into capped collection

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?

like image 774
Claudio Bisegni Avatar asked Dec 15 '25 10:12

Claudio Bisegni


2 Answers

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.

like image 143
Gates VP Avatar answered Dec 17 '25 00:12

Gates VP


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.

like image 37
BrightShadow Avatar answered Dec 17 '25 00:12

BrightShadow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!