Skip to content
Snippets Groups Projects
Commit 668c3098 authored by Lee WooChang's avatar Lee WooChang
Browse files

fix: combination 이름 업데이트 오류 수정

parent 4add93e5
No related branches found
No related tags found
1 merge request!19조합 이름 변경 에러 수정
Pipeline #10819 passed
import pool from '../db.js';
const myRepository = {
async checkUserExists(userId) {
const query = `
SELECT 1
FROM users
WHERE id = $1
`;
const values = [userId];
const { rows } = await pool.query(query, values);
return rows.length > 0;
},
async getCombinationById(combinationId) {
const query = `
SELECT id, name, owner_id AS "userId"
FROM combinations
WHERE id = $1
`;
const values = [combinationId];
const { rows } = await pool.query(query, values);
return rows.length > 0 ? rows[0] : null;
},
async getCombinationsByUserId(userId) {
const query = `
SELECT id, name
......@@ -49,7 +73,7 @@ const myRepository = {
async updateCombinationName(combinationId, newName) {
const query = `
UPDATE combinations
SET name = $1, updated_at = NOW()
SET name = $1
WHERE id = $2
`;
const values = [newName, combinationId];
......
......@@ -27,7 +27,7 @@ myRouter.patch(
wrapAsync(async (req, res) => {
const { combinationId } = req.params;
const { newName } = req.body;
const userId = req.user.id;
const userId = req.user?.userId;
if (!newName || typeof newName !== 'string') {
throw new ReportableError(400, '유효한 새로운 이름이 필요합니다.');
......
......@@ -79,7 +79,7 @@ const PartService = {
const allCombinations = await PartRepository.getAllCombinations();
return allCombinations.map((combination) => ({
partIds: combination.partids,
}));;
}));
},
async getFilteredCombinations(filters) {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment