Skip to content

Commit

Permalink
No commit message
Browse files Browse the repository at this point in the history
  • Loading branch information
TatianaS7 committed Jan 8, 2024
1 parent d91d713 commit ab4994b
Showing 1 changed file with 16 additions and 16 deletions.
32 changes: 16 additions & 16 deletions server/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ app.get("/api/database/search", async (req, res) => {
OR instrument LIKE ?
OR status LIKE ?
OR notes LIKE ?`;
const [search] = await pool.query(searchSql, [`%${q}%`, `%${q}%`, `%${q}%`, `%${q}%`, `%${q}%`, `%${q}%`, `%${q}%`, `%${q}%`]);
const [search] = pool.query(searchSql, [`%${q}%`, `%${q}%`, `%${q}%`, `%${q}%`, `%${q}%`, `%${q}%`, `%${q}%`, `%${q}%`]);

res.status(200).json({ search });
} catch (error) {
Expand All @@ -70,7 +70,7 @@ app.post("/api/database/new", async (req,res) => {
`SELECT * FROM prints
WHERE catalog_number LIKE ?`;

[check] = await pool.query(checkExistingRecord, [catalog_number]);
[check] = pool.query(checkExistingRecord, [catalog_number]);

if (check.length > 0) {
res.status(400).json({ message: "This is a Duplicate Entry" })
Expand All @@ -80,18 +80,18 @@ app.post("/api/database/new", async (req,res) => {
`INSERT INTO prints (catalog_number, artist, image, year, location, size, instrument, status, notes, date_sold)
VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?)`;

await pool.query(insertRecord, [
catalog_number,
artist,
image,
year,
location,
size,
instrument,
status,
notes,
date_sold,
]);
pool.query(insertRecord, [
catalog_number,
artist,
image,
year,
location,
size,
instrument,
status,
notes,
date_sold,
]);
res.status(200).json({ message: "Record Added!"});
}
} catch (error) {
Expand Down Expand Up @@ -121,7 +121,7 @@ app.put("/api/database/update/:id", async (req, res) => {
date_sold = ?
WHERE idprints = ?`;

await pool.query(updateRecord, [catalog_number, artist, image, year, location, size, instrument, status, notes, date_sold, printId]);
pool.query(updateRecord, [catalog_number, artist, image, year, location, size, instrument, status, notes, date_sold, printId]);

res.status(200).json({ message: "Record updated!" });
} catch (error) {
Expand All @@ -135,7 +135,7 @@ app.put("/api/database/update/:id", async (req, res) => {


// Start the server
const PORT = process.env.DB_PORT || 3000;
const PORT = process.env.DB_PORT || 5501;
app.listen(PORT, () => {
console.log(`Server is running on port ${PORT}`);
});
Expand Down

0 comments on commit ab4994b

Please sign in to comment.