src/DataBroker/DataBroker.js
/**
	 * Delete insertions and restore deleted
	 * @returns {Promise<Number>}  The total number of rows affected
	 */
Delete insertions and restore deleted
@returns {Promise}  The total number of rows affected
Delete insertions and restore deleted @returns { Promise } The total number of rows affected
async cleanup() {
		let totalAffectedRows = 0;
		for (const table of Object.keys(this.ids)) {
			for (const idOrKey of this.ids[table]) {
				const where = typeof idOrKey === 'number' ? { id: idOrKey } : idOrKey;
				const { affectedRows } = await this.db.deleteFrom(table, where, 1);
				totalAffectedRows += affectedRows;
			}
		}
		this.ids = {};
		for (const table of Object.keys(this.deleted)) {
			const { affectedRows } = await this.db.insertExtended(
				table,
				this.deleted[table]
			);
			totalAffectedRows += affectedRows;
		}
		this.deleted = {};
		return totalAffectedRows;
	}
async cleanup ( ) { let totalAffectedRows = 0 ; for ( const table of Object . keys ( this . ids ) ) { for ( const idOrKey of this . ids [ table ] ) { const where = typeof idOrKey === 'number' ? { id : idOrKey } : idOrKey ; const { affectedRows } = await this . db . deleteFrom ( table , where , 1 ) ; totalAffectedRows += affectedRows ; } } this . ids = { } ; for ( const table of Object . keys ( this . deleted ) ) { const { affectedRows } = await this . db . insertExtended ( table , this . deleted [ table ] ) ; totalAffectedRows += affectedRows ; } this . deleted = { } ; return totalAffectedRows ; }
Delete insertions and restore deleted
 @returns {Promise<Number>}  The total number of rows affected
Delete insertions and restore deleted @returns { Promise<Number > } The total number of rows affected
// cleanup inserted records // re-insert deleted records