feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
31
api.hyungi.net/models/pipeSpecModel.js
Normal file
31
api.hyungi.net/models/pipeSpecModel.js
Normal file
@@ -0,0 +1,31 @@
|
||||
const { getDb } = require('../dbPool');
|
||||
|
||||
// 전체 조회
|
||||
const getAll = async () => {
|
||||
const db = await getDb();
|
||||
const [rows] = await db.query(`SELECT * FROM PipeSpecs ORDER BY material, diameter_in`);
|
||||
return rows;
|
||||
};
|
||||
|
||||
// 등록
|
||||
const create = async ({ material, diameter_in, schedule }) => {
|
||||
const db = await getDb();
|
||||
const [result] = await db.query(
|
||||
`INSERT INTO PipeSpecs (material, diameter_in, schedule)
|
||||
VALUES (?, ?, ?)`,
|
||||
[material, diameter_in, schedule]
|
||||
);
|
||||
return result.insertId;
|
||||
};
|
||||
|
||||
// 삭제
|
||||
const remove = async (spec_id) => {
|
||||
const db = await getDb();
|
||||
const [result] = await db.query(
|
||||
`DELETE FROM PipeSpecs WHERE spec_id = ?`,
|
||||
[spec_id]
|
||||
);
|
||||
return result.affectedRows;
|
||||
};
|
||||
|
||||
module.exports = { getAll, create, remove };
|
||||
Reference in New Issue
Block a user