Skip to content

Commit

Permalink
update query in transactionModel.js
Browse files Browse the repository at this point in the history
  • Loading branch information
hatami30 committed Dec 7, 2023
1 parent c676e89 commit 0113c7d
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 8 deletions.
4 changes: 2 additions & 2 deletions api.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const transactionRouter = require('./src/routes/transactionRouter.js');
const errorMiddleware = require('./src/middleware/errorMiddleware.js');
const logger = pino();
const app = express();
const v1 = express.Router();
const port = process.env.PORT || 3001;

// middleware
Expand All @@ -18,7 +19,6 @@ app.use(express.urlencoded({ extended: true }));
app.use(errorMiddleware);

// routes
v1 = express.Router();
app.use("/v1", v1);

// menu & category routes
Expand All @@ -28,7 +28,7 @@ v1.use("/menu", menuRouter);
v1.use("/transaction", transactionRouter);

// start the server
app.listen(process.env.PORT, (err) => {
app.listen(port, (err) => {
if (err) {
logger.error('Error starting the server:', err);
} else {
Expand Down
4 changes: 2 additions & 2 deletions src/models/transactionModel.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ async function createTransaction({ nomor_meja, nama_pemesan, orders, status_pemb
}

const query = `
INSERT INTO transactions (nomor_meja, nama_pemesan, orders, status_pembayaran)
INSERT INTO transaction (nomor_meja, nama_pemesan, orders, status_pembayaran)
VALUES ($1, $2, $3::json, $4)
RETURNING *
`;
Expand All @@ -31,7 +31,7 @@ async function createTransaction({ nomor_meja, nama_pemesan, orders, status_pemb
// get all transaction model
async function getAllTransaction() {
try {
const result = await pool.query('SELECT * FROM transactions');
const result = await pool.query('SELECT * FROM transaction');
return result.rows;
} catch (error) {
logger.error("Error fetching data from transactions:", error);
Expand Down
4 changes: 0 additions & 4 deletions src/routes/menuRouter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,6 @@ const express = require('express');
const menuController = require('../controllers/menuController.js');
const menuRouter = express.Router();

menuRouter.get("/", (req, res) => {
res.status(200).json({ message: "Ini data API SE.Kopi" });
});

// menu & category router
menuRouter.get("/", menuController.getAllMenuController);
menuRouter.get("/:category", menuController.getMenuByCategoryController);
Expand Down

0 comments on commit 0113c7d

Please sign in to comment.