diff --git a/examples/mysql/index.ts b/examples/mysql/index.ts deleted file mode 100644 index 7e9af18..0000000 --- a/examples/mysql/index.ts +++ /dev/null @@ -1,34 +0,0 @@ -import { createDatabase } from "../../src"; -import mysqlConnector from "../../src/connectors/mysql2" - - -async function main() { - const db = createDatabase(mysqlConnector({ - host: "localhost", - user: "root", - password: "root", - database: "db0", - })); - - await db.sql`CREATE TABLE IF NOT EXISTS users ( - id INT PRIMARY KEY AUTO_INCREMENT, - name VARCHAR(255) NOT NULL - )`; - - await db.sql`INSERT INTO users (name) VALUES (${randomValue()})`; - - const users = await db.sql`SELECT * FROM users`; - - console.log({ rows: users.rows }); -} - -// eslint-disable-next-line unicorn/prefer-top-level-await -main().catch((error) => { - console.error(error); - // eslint-disable-next-line unicorn/no-process-exit - process.exit(1); -}); - -function randomValue() { - return Math.random().toString(36).slice(7); -} diff --git a/examples/mysql/package.json b/examples/mysql/package.json deleted file mode 100644 index 456df05..0000000 --- a/examples/mysql/package.json +++ /dev/null @@ -1,10 +0,0 @@ -{ - "name": "db0-with-mysql", - "private": true, - "scripts": { - "start": "jiti ./index.ts" - }, - "devDependencies": { - "db0": "latest" - } -} diff --git a/src/connectors/mysql2.ts b/src/connectors/mysql2.ts index 005d8a5..14fa17d 100644 --- a/src/connectors/mysql2.ts +++ b/src/connectors/mysql2.ts @@ -18,6 +18,7 @@ export default function mysqlConnector(opts: mysql.ConnectionOptions) { return { name: "mysql", + dialect: "mysql", exec(sql: string) { return getConnection().then((c) => c.query(sql).then((res) => res[0])); }, diff --git a/test/connectors/mysql2.test.ts b/test/connectors/mysql2.test.ts index 2cd906a..aa9c0e2 100644 --- a/test/connectors/mysql2.test.ts +++ b/test/connectors/mysql2.test.ts @@ -6,6 +6,7 @@ describe.runIf(process.env.POSTGRESQL_URL)( "connectors: mysql2.test", () => { testConnector({ + dialect: "mysql", connector: connector({ host: "localhost", user: "root",