Skip to content
This repository was archived by the owner on May 25, 2025. It is now read-only.

Commit 4b3f3b3

Browse files
feat: runSQLString
1 parent bc27d6b commit 4b3f3b3

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/mysql.db.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -218,6 +218,21 @@ export class MysqlDB extends BaseCommonDB implements CommonDB {
218218
})
219219
}
220220

221+
/**
222+
* Allows to run semicolon-separated "SQL file".
223+
* E.g "ddl reset script".
224+
*/
225+
async runSQLString(s: string): Promise<void> {
226+
const queries = s
227+
.split(';')
228+
.map(s => s.trim())
229+
.filter(Boolean)
230+
231+
for await (const sql of queries) {
232+
await this.runSQL({ sql })
233+
}
234+
}
235+
221236
override async runQueryCount<ROW extends ObjectWithId>(
222237
q: DBQuery<ROW>,
223238
_opt?: CommonDBOptions,

0 commit comments

Comments
 (0)