MOBILE-3977 db: Implement method to log history

main
Noel De Martin 2022-02-03 13:26:42 +01:00
parent fdd5d5d8a5
commit effe53807a
1 changed files with 11 additions and 0 deletions

View File

@ -38,6 +38,17 @@ export class CoreDbProvider {
return CoreAppProvider.isAutomated(); 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. * Log a query.
* *