Skip to content
Snippets Groups Projects

조합 API 추가

Merged Lee WooChang requested to merge feat/combinations into main
3 files
+ 81
0
Compare changes
  • Side-by-side
  • Inline

Files

+ 30
0
@@ -57,6 +57,36 @@ const PartRepository = {
@@ -57,6 +57,36 @@ const PartRepository = {
const result = await pool.query(query, queryValues);
const result = await pool.query(query, queryValues);
return result.rows;
return result.rows;
},
},
 
 
async getAllCombinations() {
 
const query = `
 
SELECT array_agg(r.part_id) AS partIds
 
FROM combinations c
 
LEFT JOIN relations r ON c.id = r.combination_id
 
GROUP BY c.id;
 
`;
 
 
const result = await pool.query(query);
 
return result.rows;
 
},
 
 
async getFilteredCombinations(queryValues) {
 
const query = `
 
SELECT
 
c.id AS combination_id,
 
array_agg(r.part_id) AS partIds
 
FROM combinations c
 
LEFT JOIN relations r ON c.id = r.combination_id
 
WHERE r.combination_id IN (
 
SELECT DISTINCT combination_id
 
FROM relations
 
WHERE part_id = ANY($1::int[])
 
)
 
GROUP BY c.id;
 
`;
 
const result = await pool.query(query, queryValues);
 
return result.rows;
 
},
};
};
export default PartRepository;
export default PartRepository;
Loading