Skip to content

Commit

Permalink
added doc
Browse files Browse the repository at this point in the history
  • Loading branch information
LordFarquaadtheCreator committed Jun 4, 2024
1 parent a26406e commit a121f67
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
6 changes: 5 additions & 1 deletion routes/databaseFunctions.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
import { Client } from "pg";

/**
* Function to add all items from values to database
* Assumes values array correctly maps to the database schema (no empty values, etc.)
*/
export function addToDB(client: Client, values: Array<any>) {
const query = `
INSERT INTO projects (name, "short-desc", "long-desc", team, link, image, "tech-stack", cohort, topic)
Expand All @@ -8,6 +12,6 @@ export function addToDB(client: Client, values: Array<any>) {
try {
return client.query(query, values);
} catch (e: any) {
throw Error(e.toString());
throw Error(e);
}
}
1 change: 0 additions & 1 deletion routes/projectsDB.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,6 @@ router.get("/get", (req: any, res: any) => {
});

router.post("/add", (req: any, res: any) => {
const keys: Array<any> = Object.keys(req.body);
const values: Array<any> = Object.values(req.body);

try {
Expand Down

0 comments on commit a121f67

Please sign in to comment.