deno.land / x / abc@v1.3.3 / examples / ultra_cat_app / db.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Client } from "./deps.ts";
const DB = await new Client().connect({ hostname: "127.0.0.1", username: "root", password: "",});const dbname = "ultra_cat_app";
await DB.execute(`CREATE DATABASE IF NOT EXISTS ${dbname}`);await DB.execute(`USE ${dbname}`);
await DB.execute(`CREATE TABLE IF NOT EXISTS users ( id int(11) NOT NULL AUTO_INCREMENT, username varchar(20) NOT NULL UNIQUE, password varchar(32) NOT NULL, created_at timestamp not null default current_timestamp, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;`);
await DB.execute(`CREATE TABLE IF NOT EXISTS cats ( id int(11) NOT NULL AUTO_INCREMENT, name varchar(20) NOT NULL, age int NOT NULL, created_at timestamp not null default current_timestamp, PRIMARY KEY (id)) ENGINE=InnoDB DEFAULT CHARSET=utf8;`);
export default DB;
abc

Version Info

Tagged at
3 years ago