diff --git a/CHANGELOG.md b/CHANGELOG.md index 50fe68cae2b..2c19f152a84 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,6 +2,7 @@ # RxDB Changelog +- ADD `postCleanup` hook. diff --git a/src/hooks.ts b/src/hooks.ts index 27c9360658b..497c4d5a0d8 100644 --- a/src/hooks.ts +++ b/src/hooks.ts @@ -83,6 +83,9 @@ export const HOOKS: { [k: string]: any[]; } = { */ postRemoveRxDatabase: [], + + postCleanup: [], + /** * runs before the replication writes the rows to master * but before the rows have been modified diff --git a/src/plugins/attachments/index.ts b/src/plugins/attachments/index.ts index db76e71e774..34543468d52 100644 --- a/src/plugins/attachments/index.ts +++ b/src/plugins/attachments/index.ts @@ -19,7 +19,10 @@ import type { RxAttachmentCreator, RxAttachmentWriteData } from '../../types/index.ts'; -import { assignMethodsToAttachment, ensureSchemaSupportsAttachments } from './attachments-utils.ts'; +import { + assignMethodsToAttachment, + ensureSchemaSupportsAttachments +} from './attachments-utils.ts'; diff --git a/src/plugins/cleanup/cleanup.ts b/src/plugins/cleanup/cleanup.ts index 47c60ec187d..df21a92d1c6 100644 --- a/src/plugins/cleanup/cleanup.ts +++ b/src/plugins/cleanup/cleanup.ts @@ -2,6 +2,7 @@ import type { RxCleanupPolicy, RxCollection } from '../../types/index.d.ts'; import { PROMISE_RESOLVE_TRUE } from '../../plugins/utils/index.ts'; import { REPLICATION_STATE_BY_COLLECTION } from '../replication/index.ts'; import { DEFAULT_CLEANUP_POLICY } from './cleanup-helper.ts'; +import { runAsyncPluginHooks } from 'rxdb-old'; /** * Even on multiple databases, @@ -93,6 +94,11 @@ export async function cleanupRxCollection( }); isDone = await RXSTORAGE_CLEANUP_QUEUE; } + + await runAsyncPluginHooks('postCleanup', { + collectionName: rxCollection.name, + databaseName: rxDatabase.name + }); } /** diff --git a/src/types/rx-plugin.d.ts b/src/types/rx-plugin.d.ts index d6c3fcce5ae..36213a0f976 100644 --- a/src/types/rx-plugin.d.ts +++ b/src/types/rx-plugin.d.ts @@ -144,6 +144,10 @@ export interface RxPlugin { }>; preMigrateDocument?: RxPluginHooks; postMigrateDocument?: RxPluginHooks; + postCleanup?: RxPluginHooks<{ + databaseName: string; + collectionName: string; + }>; preReplicationMasterWrite?: RxPluginHooks<{ rows: RxReplicationWriteToMasterRow[]; collection: RxCollection;