diff --git a/src/core/services/db.ts b/src/core/services/db.ts index 727b5424d..489d44072 100644 --- a/src/core/services/db.ts +++ b/src/core/services/db.ts @@ -38,6 +38,17 @@ export class CoreDbProvider { return CoreAppProvider.isAutomated(); } + /** + * Print query history in console. + */ + printHistory(): void { + const substituteParams = ({ sql, params }: CoreDbQueryLog) => + Object.values(params ?? []).reduce((sql: string, param: string) => sql.replace('?', param), sql); + + // eslint-disable-next-line no-console + console.log(this.queryLogs.map(substituteParams).join('\n')); + } + /** * Log a query. *