mirror of
https://github.com/khairul169/cebol.git
synced 2025-04-28 08:39:33 +07:00
19 lines
445 B
TypeScript
19 lines
445 B
TypeScript
import { Database } from "bun:sqlite";
|
|
|
|
const dbPath = process.cwd() + "/storage/database.sqlite";
|
|
const db = new Database(dbPath);
|
|
|
|
export const initDb = () => {
|
|
db.exec(
|
|
`CREATE TABLE IF NOT EXISTS links (
|
|
id INTEGER PRIMARY KEY AUTOINCREMENT,
|
|
alias TEXT NOT NULL UNIQUE,
|
|
url TEXT NOT NULL,
|
|
clicks INTEGER DEFAULT 0,
|
|
createdAt DATETIME DEFAULT CURRENT_TIMESTAMP
|
|
)`
|
|
);
|
|
};
|
|
|
|
export default db;
|