-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathkysely.ts
90 lines (78 loc) · 1.84 KB
/
kysely.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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
import { Kysely, PostgresDialect, sql, Generated, ColumnType } from 'kysely';
import { Pool } from 'pg';
export type Json = JsonValue;
export type JsonArray = JsonValue[];
export type JsonPrimitive = boolean | number | string | null;
export type JsonValue = JsonArray | JsonObject | JsonPrimitive;
export type Numeric = ColumnType<string, number | string, number | string>;
export type JsonObject = {
[K in string]?: JsonValue;
};
export interface UserTable {
id: Generated<number>;
created_at: Generated<Date>;
name: string;
image: string;
is_admin: boolean;
admin_hackathons: string;
}
export interface TeamsTable {
id: Generated<number>;
fids: number[];
name: string;
description: string;
hackathon_id: number;
submitted_at?: Date;
wallet_address: string;
embeds: Json;
}
export interface HackathonsTable {
id: Generated<number>;
name: string;
description: string;
slug: string;
square_image: string;
start_date: Date;
end_date: Date;
created_at: Generated<Date>;
tracks: Json;
bounties: Json;
schedule: Json;
}
export interface InvitesTable {
id: Generated<number>;
token: string;
created_at: Generated<Date>;
expires_at: Date;
user_id: number;
accepted_at?: Date;
accepted_by?: number;
team_id?: number;
}
export interface TicketsTable {
id: Generated<number>;
user_id: number;
user_address: string;
hackathon_id: number;
txn_hash: string;
ticket_type: string;
amount: number;
created_at: Generated<Date>;
}
export interface Database {
users: UserTable;
teams: TeamsTable;
hackathons: HackathonsTable;
invites: InvitesTable;
tickets: TicketsTable;
}
const connectionString = process.env.DATABASE_URL ?? "";
const pool = new Pool({
connectionString,
});
export const db = new Kysely<Database>({
dialect: new PostgresDialect({
pool,
}),
});
export { sql } from 'kysely';