Skip to content

Commit ff0c1b2

Browse files
committedAug 1, 2024
format
1 parent a64d51f commit ff0c1b2

File tree

1 file changed

+17
-19
lines changed

1 file changed

+17
-19
lines changed
 

‎src/modules/sql/pool.ts

+17-19
Original file line numberDiff line numberDiff line change
@@ -33,29 +33,29 @@ export class MemorySqlite {
3333
)
3434

3535
static {
36-
this.pool.on("factoryCreateError", function(err) {
37-
console.log('factoryCreateError',err);
38-
});
39-
40-
this.pool.on("factoryDestroyError", function(err) {
41-
console.log('factoryDestroyError',err);
42-
});
36+
this.pool.on('factoryCreateError', function (err) {
37+
console.log('factoryCreateError', err)
38+
})
39+
40+
this.pool.on('factoryDestroyError', function (err) {
41+
console.log('factoryDestroyError', err)
42+
})
4343
}
4444

4545
static async acquire(): Promise<DB> {
4646
const db = await this.pool.acquire()
4747

4848
// delete all tables
49-
// const tables = db
50-
// .prepare<
51-
// [],
52-
// { name: string }
53-
// >("SELECT name FROM sqlite_master WHERE type='table'")
54-
// .all()
49+
const tables = db
50+
.prepare<
51+
[],
52+
{ name: string }
53+
>("SELECT name FROM sqlite_master WHERE type='table'")
54+
.all()
5555

56-
// for (const table of tables) {
57-
// db.prepare(`DELETE FROM ${table.name}`).run()
58-
// }
56+
for (const table of tables) {
57+
db.prepare(`DELETE FROM ${table.name}`).run()
58+
}
5959

6060
return db
6161
}
@@ -64,9 +64,7 @@ export class MemorySqlite {
6464
await this.pool.release(db)
6565
}
6666

67-
static async withMemDb<T>(
68-
callback: (db: DB) => Promise<T>
69-
): Promise<T> {
67+
static async withMemDb<T>(callback: (db: DB) => Promise<T>): Promise<T> {
7068
const db = await this.acquire()
7169
try {
7270
return await callback(db)

0 commit comments

Comments
 (0)
Please sign in to comment.