File tree Expand file tree Collapse file tree 2 files changed +52
-0
lines changed
starter-example/app/query Expand file tree Collapse file tree 2 files changed +52
-0
lines changed Original file line number Diff line number Diff line change
1
+ import postgres from 'postgres' ;
2
+
3
+ const sql = postgres ( process . env . POSTGRES_URL ! , { ssl : 'require' } ) ;
4
+
5
+ async function listInvoices ( ) {
6
+ const data = await sql `
7
+ SELECT invoices.amount, customers.name
8
+ FROM invoices
9
+ JOIN customers ON invoices.customer_id = customers.id
10
+ WHERE invoices.amount = 666;
11
+ ` ;
12
+
13
+ return data ;
14
+ }
15
+
16
+ export async function GET ( ) {
17
+ // return Response.json({
18
+ // message:
19
+ // 'Uncomment this file and remove this line. You can delete this file when you are finished.',
20
+ // });
21
+ try {
22
+ return Response . json ( await listInvoices ( ) ) ;
23
+ } catch ( error ) {
24
+ return Response . json ( { error } , { status : 500 } ) ;
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ // import postgres from 'postgres';
2
+
3
+ // const sql = postgres(process.env.POSTGRES_URL!, { ssl: 'require' });
4
+
5
+ // async function listInvoices() {
6
+ // const data = await sql`
7
+ // SELECT invoices.amount, customers.name
8
+ // FROM invoices
9
+ // JOIN customers ON invoices.customer_id = customers.id
10
+ // WHERE invoices.amount = 666;
11
+ // `;
12
+
13
+ // return data;
14
+ // }
15
+
16
+ export async function GET ( ) {
17
+ return Response . json ( {
18
+ message :
19
+ 'Uncomment this file and remove this line. You can delete this file when you are finished.' ,
20
+ } ) ;
21
+ // try {
22
+ // return Response.json(await listInvoices());
23
+ // } catch (error) {
24
+ // return Response.json({ error }, { status: 500 });
25
+ // }
26
+ }
You can’t perform that action at this time.
0 commit comments