Search code examples
node.jsmongodbmosca

When are Mosca pubsubCollection documents removed?


I need to store the data sent by devices in a collection. However, I dont want it in the format used by the pubsubCollection. So I decided to store it using server.on('published').

So when are the documents from pubsubCollection removed by mosca? I dont want redundant data.

PS: I know I couldn't put this question properly, if you down vote, do tell me why.


Solution

  • The collection is a capped collection in mongodb (see https://docs.mongodb.org/manual/core/capped-collections/), and the packets will be automatically removed by MongoDB when they reach the maximum size or disk or the maximum amount of packets. Both these values are tweakable.