diff --git a/server/models/Users.ts b/server/models/Users.ts index 6ad883023..cb608f1bd 100644 --- a/server/models/Users.ts +++ b/server/models/Users.ts @@ -31,6 +31,7 @@ class Users { }); db.ensureIndex({fieldName: 'username', unique: true}); + db.setAutocompactionInterval(config.dbCleanInterval); return db; })(); diff --git a/server/services/feedService.ts b/server/services/feedService.ts index ea0796e00..36c139aa7 100644 --- a/server/services/feedService.ts +++ b/server/services/feedService.ts @@ -21,6 +21,7 @@ class FeedService extends BaseService> { constructor(...args: ConstructorParameters) { super(...args); + this.db.setAutocompactionInterval(config.dbCleanInterval); this.onServicesUpdated = async () => { // Execute once only. diff --git a/server/services/notificationService.ts b/server/services/notificationService.ts index 2244cf15f..5ec8f1007 100644 --- a/server/services/notificationService.ts +++ b/server/services/notificationService.ts @@ -26,6 +26,7 @@ class NotificationService extends BaseService { constructor(...args: ConstructorParameters) { super(...args); + this.db.setAutocompactionInterval(config.dbCleanInterval); (async () => { const notifications = await this.db.findAsync({}).catch(() => undefined); diff --git a/server/services/settingService.ts b/server/services/settingService.ts index 1481f7d70..c645b5d00 100644 --- a/server/services/settingService.ts +++ b/server/services/settingService.ts @@ -21,6 +21,11 @@ class SettingService extends BaseService { filename: path.join(config.dbPath, this.user._id, 'settings', 'settings.db'), }); + constructor(...args: ConstructorParameters) { + super(...args); + this.db.setAutocompactionInterval(config.dbCleanInterval); + } + async destroy(drop: boolean) { if (drop) { await this.db.dropDatabaseAsync();