Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 | 11x 11x 15x 15x 15x 11x 3x 3x 11x 2x 2x 11x 1x 1x 1x 11x 1x 1x 11x 1x 1x 11x | const db = require("../../../database/connection"); const insert = (coursePhase) => { const query = "INSERT INTO course_phase VALUES ($1, $2) " + "RETURNING *"; // returns inserted row const params = [coursePhase.courseId, coursePhase.phaseId]; return db.query(query, params); }; const findAllByCourseId = (courseId) => { const query = "SELECT * FROM course_phase WHERE course_id=$1"; return db.query(query, [courseId]); }; const findAllByPhaseId = (phaseId) => { const query = "SELECT * FROM course_phase WHERE phase_id=$1"; return db.query(query, [phaseId]); }; const find = (courseId, phaseId) => { const query = "SELECT * FROM course_phase WHERE course_id=$1 AND phase_id=$2"; const params = [courseId, phaseId]; return db.query(query, params); }; const removeByCourseId = (courseId) => { const query = "DELETE FROM course_phase WHERE course_id = $1 RETURNING *"; return db.query(query, [courseId]); }; const removeByPhaseId = (phaseId) => { const query = "DELETE FROM course_phase WHERE phase_id = $1 RETURNING *"; return db.query(query, [phaseId]); }; module.exports = { insert, findAllByCourseId, findAllByPhaseId, find, removeByCourseId, removeByPhaseId, }; |