Allow how many to keep in DB by config 'retainCount'
This commit is contained in:
parent
b8ea3bbd5b
commit
13d30827aa
|
@ -287,14 +287,15 @@ exports.getModule = class OnelinerzModule extends MenuModule {
|
||||||
);
|
);
|
||||||
},
|
},
|
||||||
function removeOld(callback) {
|
function removeOld(callback) {
|
||||||
// keep 25 max most recent items - remove the older ones
|
// keep 25 max most recent items by default - remove the older ones
|
||||||
|
const retainCount = self.menuConfig.config.retainCount || 25;
|
||||||
self.db.run(
|
self.db.run(
|
||||||
`DELETE FROM onelinerz
|
`DELETE FROM onelinerz
|
||||||
WHERE id IN (
|
WHERE id IN (
|
||||||
SELECT id
|
SELECT id
|
||||||
FROM onelinerz
|
FROM onelinerz
|
||||||
ORDER BY id DESC
|
ORDER BY id DESC
|
||||||
LIMIT -1 OFFSET 25
|
LIMIT -1 OFFSET ${retainCount}
|
||||||
);`,
|
);`,
|
||||||
callback
|
callback
|
||||||
);
|
);
|
||||||
|
|
Loading…
Reference in New Issue