mic-bot/repo/scheme.ts
2024-10-23 18:09:10 +02:00

40 lines
1.6 KiB
TypeScript

import { ColumnType, Insertable, Selectable, Updateable } from "npm:kysely";
// Shortcuts cuz my monitor is small ;(
type Nothing = undefined | null
type DateOrStr = Date | string
type WrittableOnce<type> = ColumnType<type, type, never>
type WithDefault<type> = ColumnType<type, type | Nothing, type>
export interface TableUsers {
id: ColumnType<string, string | Nothing, never>
tg_id: number | null
joined_by_referal_from_user_id: WrittableOnce<string | null>
is_chat_participant: WithDefault<boolean>
is_captcha_passed: WithDefault<boolean>
is_timeout: WithDefault<boolean>
is_banned: WithDefault<boolean>
created_at: ColumnType<Date, DateOrStr | Nothing, never>
joined_chat_at: ColumnType<Date | null, DateOrStr | Nothing, DateOrStr>
timeout_until: ColumnType<Date | null, DateOrStr | Nothing, DateOrStr | null>
}
export interface TableInviteLinks {
link: WrittableOnce<string>
expect_user_tg_id: WrittableOnce<number>
valid_until: ColumnType<Date | null, DateOrStr | Nothing, never>
}
export interface Database {
users: TableUsers
invite_links: TableInviteLinks
}
export type SelectUser = Selectable<TableUsers>
export type InsertUser = Insertable<TableUsers>
export type UpdateUser = Updateable<TableUsers>
export type SelectInviteLinks = Selectable<TableInviteLinks>
export type InsertInviteLinks = Insertable<TableInviteLinks>
export type UpdateInviteLinks = Updateable<TableInviteLinks>