Skip to content

Commit 9d7fc57

Browse files
committed
feat: add supabase query with types
1 parent 0962a51 commit 9d7fc57

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
import type { QueryData } from "@supabase/supabase-js";
2+
import { createClient } from "~/supabase/server";
3+
4+
const supabase = createClient();
5+
6+
export const getAllOrdersQuery = supabase.from("gifts").select(`
7+
id,
8+
users(id, email, full_name, avatar_url),
9+
recipient_id,
10+
gift_recipients(id, name),
11+
status,
12+
type
13+
`);
14+
15+
export type Orders = QueryData<typeof getAllOrdersQuery>;
16+
17+
export const getLinkOrdersQuery = supabase
18+
.from("gifts")
19+
.select(`
20+
id,
21+
users(id, email, full_name, avatar_url),
22+
recipient_id,
23+
gift_recipients(id, name),
24+
status,
25+
type
26+
`)
27+
.eq("type", "link");
28+
29+
export const getCustomOrdersQuery = supabase
30+
.from("gifts")
31+
.select(`
32+
id,
33+
users(id, email, full_name, avatar_url),
34+
recipient_id,
35+
gift_recipients(id, name),
36+
status,
37+
type
38+
`)
39+
.eq("type", "custom");
40+
41+
export const getStoreOrdersQuery = supabase
42+
.from("gifts")
43+
.select(`
44+
id,
45+
users(id, email, full_name, avatar_url),
46+
recipient_id,
47+
gift_recipients(id, name),
48+
status,
49+
type
50+
`)
51+
.eq("type", "store");

0 commit comments

Comments
 (0)