add drizzle orm
This commit is contained in:
5
database/index.ts
Normal file
5
database/index.ts
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
import { drizzle } from "drizzle-orm/libsql";
|
||||||
|
import Database from "libsql";
|
||||||
|
|
||||||
|
const sqlite = new Database(":memory:");
|
||||||
|
export const db = drizzle(sqlite);
|
||||||
25
database/schema.ts
Normal file
25
database/schema.ts
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
import { integer, sqliteTable, text } from "drizzle-orm/sqlite-core";
|
||||||
|
|
||||||
|
export const guilds = sqliteTable("guilds", {
|
||||||
|
id: integer("id").primaryKey(),
|
||||||
|
name: text("name"),
|
||||||
|
});
|
||||||
|
export type Guild = typeof guilds.$inferSelect;
|
||||||
|
export type InsertGuild = typeof guilds.$inferInsert;
|
||||||
|
|
||||||
|
export const users = sqliteTable("users", {
|
||||||
|
id: integer("id").primaryKey(),
|
||||||
|
name: text("name"),
|
||||||
|
opt_out: integer("opt_out"),
|
||||||
|
});
|
||||||
|
export type User = typeof users.$inferSelect;
|
||||||
|
export type InsertUser = typeof users.$inferInsert;
|
||||||
|
|
||||||
|
export const messages = sqliteTable("messages", {
|
||||||
|
id: integer("id").primaryKey(),
|
||||||
|
content: text("content"),
|
||||||
|
user_id: integer("user_id").references(() => users.id),
|
||||||
|
guild_id: integer("guild_id").references(() => guilds.id),
|
||||||
|
});
|
||||||
|
export type Message = typeof messages.$inferSelect;
|
||||||
|
export type InsertMessage = typeof messages.$inferInsert;
|
||||||
@@ -7,7 +7,8 @@
|
|||||||
},
|
},
|
||||||
"type": "module",
|
"type": "module",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"@types/bun": "latest"
|
"@types/bun": "latest",
|
||||||
|
"drizzle-kit": "^0.20.17"
|
||||||
},
|
},
|
||||||
"peerDependencies": {
|
"peerDependencies": {
|
||||||
"typescript": "^5.0.0"
|
"typescript": "^5.0.0"
|
||||||
@@ -15,6 +16,8 @@
|
|||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@huggingface/inference": "^2.6.7",
|
"@huggingface/inference": "^2.6.7",
|
||||||
"discord.js": "^14.14.1",
|
"discord.js": "^14.14.1",
|
||||||
|
"drizzle-orm": "^0.30.10",
|
||||||
|
"libsql": "^0.3.18",
|
||||||
"openai": "^4.36.0"
|
"openai": "^4.36.0"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user