Function restoreSoftDeletion

Restores soft-deleted documents from the YsfSoftDeleted collection back to their original collections.

This function retrieves deleted documents based on a selector and inserts them back into their respective collections, marking them as restored. If isTest is true, it simply returns the matching deleted documents without performing restoration.

  • Parameters

    • collectionsObject: any

      An object mapping collection names to Meteor collection instances.

    • selector: any

      A MongoDB query selector to find soft-deleted documents.

    • isTest: boolean

      If true, returns matching soft-deleted items instead of restoring them.

    Returns Promise<any[] | { newItemsCreated: string[]; numberOfDocAffected: number }>

    • If isTest is false, returns an object containing: - numberOfDocAffected: Total number of affected documents. - newItemsCreated: Array of newly inserted document IDs. - If isTest is true, returns an array of matching soft-deleted documents.