Fixed code style errors
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/tag/woodpecker Pipeline was successful

This commit is contained in:
2022-11-03 22:28:01 -04:00
parent bfb8d751b8
commit 5e895aa3ca
5 changed files with 47 additions and 39 deletions

View File

@ -2,12 +2,12 @@ const db = require('../models');
const Item = db.items;
// GET - /
exports.getIndex = async function (req, res) {
let items = await Item.findAll({
exports.getIndex = async function(req, res) {
const items = await Item.findAll({
limit: 10,
order: [
['updatedAt', 'DESC'],
]
],
});
res.render('index.twig', {

View File

@ -2,12 +2,12 @@ const db = require('../models');
const Item = db.items;
// GET - /item/add
exports.getAdd = async function (req, res) {
exports.getAdd = async function(req, res) {
res.render('item/add.twig');
};
// POST - /item/add
exports.postAdd = async function (req, res) {
exports.postAdd = async function(req, res) {
const item = await Item.create({
name: req.body.item_name,
serialNumber: req.body.item_serial,
@ -24,10 +24,12 @@ exports.postAdd = async function (req, res) {
};
// GET - /item/{id}
exports.getItem = async function (req, res) {
const item = await Item.findAll({ where: {
id: req.params.id,
}});
exports.getItem = async function(req, res) {
const item = await Item.findAll({
where: {
id: req.params.id,
},
});
res.render('item/view.twig', {
item: item[0],
@ -35,10 +37,12 @@ exports.getItem = async function (req, res) {
};
// GET - /item/{id}/edit
exports.getItemEdit = async function (req, res) {
const item = await Item.findAll({ where: {
id: req.params.id,
}});
exports.getItemEdit = async function(req, res) {
const item = await Item.findAll({
where: {
id: req.params.id,
},
});
res.render('item/edit.twig', {
item: item[0],
@ -46,14 +50,16 @@ exports.getItemEdit = async function (req, res) {
};
// POST - /item/{id}/edit
exports.postItemEdit = async function (req, res) {
exports.postItemEdit = async function(req, res) {
// fetch item from DB
const itemSearch = await Item.findAll({ where: {
id: req.params.id,
}});
const itemSearch = await Item.findAll({
where: {
id: req.params.id,
},
});
// retrieve the item record from the array for ease of use
let item = itemSearch[0];
const item = itemSearch[0];
// update item attributes
item.name = req.body.item_name;