4466ba436b
## Description This PR ensures that the default prettier config is used for examples and templates. This config is compatible with `prettier@3` as well (upgrading prettier is bigger change that can be a future PR). ## Changes - Updated `.prettierrc.json` in root with `"trailingComma": "es5"` (will be needed upgrading to prettier@3) - Added `examples/.prettierrc.json` with default config (this will change every example) - Added `packages/create-next-app/templates/.prettierrc.json` with default config (this will change every template) ## Related - Fixes #54402 - Closes #54409
35 lines
707 B
TypeScript
35 lines
707 B
TypeScript
import sql from "./db";
|
|
|
|
export interface ToDo {
|
|
id: number;
|
|
text: string;
|
|
done: boolean;
|
|
}
|
|
|
|
export async function list() {
|
|
return await sql<ToDo[]>`
|
|
SELECT id, text, done FROM todos
|
|
ORDER BY id
|
|
`;
|
|
}
|
|
|
|
export async function create(todo: ToDo) {
|
|
return await sql<ToDo[]>`
|
|
INSERT INTO todos (text, done) VALUES (${todo.text}, false)
|
|
RETURNING id, text, done
|
|
`;
|
|
}
|
|
|
|
export async function update(todo: ToDo) {
|
|
return await sql<ToDo[]>`
|
|
UPDATE todos SET done=${todo.done} WHERE id=${todo.id}
|
|
RETURNING id, text, done
|
|
`;
|
|
}
|
|
|
|
export async function remove(todo: ToDo) {
|
|
return await sql<ToDo[]>`
|
|
DELETE FROM todos WHERE id=${todo.id}
|
|
RETURNING id, text, done
|
|
`;
|
|
}
|