Skip to content

Commit

Permalink
[ADD] (#37) - adding column type
Browse files Browse the repository at this point in the history
  • Loading branch information
DongWooE committed Dec 13, 2021
1 parent e8f9314 commit 1361a86
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
18 changes: 17 additions & 1 deletion server/api/routes/v1/table/controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,22 @@ const showTables = async(req,res,next)=>{
}
}

const descTable = async(req,res,next)=>{
const {name} = req.params;
try {
const q = `DESC ${name}`;
let doc = await poolQuery(q);
doc = doc[0].map(item=>{
delete item.Extra
return item;
});
return res.json(createResponse(res,doc));
} catch (error) {
console.error(error);
next(error);
}
}

const createTable = async(req,res,next)=>{
const body = req.body;
try {
Expand Down Expand Up @@ -50,4 +66,4 @@ const dropTable = async(req,res,next)=>{
next(error);
}
}
module.exports = {showTables, createTable, dropTable}
module.exports = {showTables, createTable, dropTable, descTable};
1 change: 1 addition & 0 deletions server/api/routes/v1/table/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ const router = Router();
const controller = require('./controller.js');

router.get('/',controller.showTables);
router.get('/single/:name', controller.descTable);
router.delete('/:name',controller.dropTable);
router.post('/',controller.createTable);

Expand Down

0 comments on commit 1361a86

Please sign in to comment.