-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdb.ts
34 lines (31 loc) · 806 Bytes
/
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 { createClient } from "https://esm.sh/@supabase/[email protected]";
const supabaseUrl = Deno.env.get("SUPABASE_URL")!;
const supabaseKey = Deno.env.get("SUPABASE_KEY")!;
const supabase = createClient(supabaseUrl, supabaseKey);
export interface App {
id: number;
title: string;
description: string;
author: string;
comment: string;
}
export async function findAll() {
const result = await supabase
.from("contest")
.select()
.order("id", { ascending: false });
return result.data as App[];
}
export async function insert(data: {
title: string;
description: string;
author: string;
comment: string;
}) {
await supabase.from("contest").insert({
title: data.title,
descripion: data.description,
author: data.author,
comment: data.comment,
});
}