Skip to content

Commit

Permalink
chore: cleanup sql formatting sample
Browse files Browse the repository at this point in the history
  • Loading branch information
zenlex committed Apr 9, 2024
1 parent c2298b9 commit d8fefba
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions services/proposals.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,21 @@ import { Proposal, PendingProposal } from '../types/proposal';
async function index() {
const pool = await getPool();
return await pool.connect(async (connection) => {
const rows = await connection.any(sql.type(Proposal)`SELECT * FROM proposals;`)
const rows = await connection.any(
sql.type(Proposal)`
SELECT * FROM proposals;`)

return rows;
});
}

async function store(data: PendingProposal) {
const pool = await getPool();
return await pool.connect(async (connection) => {
const proposal = await connection.one(sql.type(Proposal)`INSERT INTO proposals (title, summary, description, type) VALUES (${data.title}, ${data.summary}, ${data.description}, ${data.type}) RETURNING *;`)
const proposal = await connection.one(sql.type(Proposal)`
INSERT INTO proposals (title, summary, description, type)
VALUES (${data.title}, ${data.summary}, ${data.description}, ${data.type})
RETURNING *;`)
});
}

Expand Down

0 comments on commit d8fefba

Please sign in to comment.