Component that removes old entries in database models.

By @mantradev

Install with:

$ mantrad download-component dbremoveolder@1.0.0

Or install last version with:

$ mantrad download-component dbremoveolder


dbremoveolder Mantra component

Component to remove all data entities older than a given time. This component only expose an API method to perform that task.

API exposed by dbremoveolder

async Mantra.api.dbremoveolder.remove( Mantra, options )

Remove old row from a database entity according to data params


  • options: object with the following properties
    • entities: database instance of the entities table to remove old rows.
    • seconds: seconds old to remove old rows from entities according to "created" field

Returns: The method returns the number of rows removed.

Sample and recommendations

This method can be take time to complete depending of the number of rows to remove.

It's recommended to call this component in backgraund applications for maintenance purposes.

Remove "logs entity" rows defined by "logs" component older than 24 hours:

await Mantra.api.dbremoveolder.remove( Mantra, {
    entities: MantraAPI.ComponentEntities("logs").logs,
    seconds: 60*60*24