Skip to content

Commit

Permalink
refactor: use mysql
Browse files Browse the repository at this point in the history
  • Loading branch information
KoichiKiyokawa committed Jun 11, 2020
1 parent 8e08a3b commit 46a4739
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 5 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@

test.db
test.db
.env
5 changes: 5 additions & 0 deletions dotenv.sample
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
hostname=localhost
username=username
db=dbname
poolSize=3
password=password
8 changes: 4 additions & 4 deletions src/infrastructure/SqlConnection.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
import { DB } from "https://deno.land/x/[email protected]/mod.ts";
import { config } from "https://deno.land/x/dotenv/mod.ts";
import { Client } from "https://deno.land/x/mysql/mod.ts";
import { IDbConnection } from "../interfaces/database/IDbConnection.ts";

const db = new DB("test.db");
const client = await new Client().connect(config())

// SQLとの接続部分
export class SqlConnection implements IDbConnection {
// 与えられたSQLクエリを実行する
async execute(query: string, args: any[]) {
const result = db.query(query, args);
// db.close();
const result = client.query(query, args);
return result;
}
}

0 comments on commit 46a4739

Please sign in to comment.