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 = (videoPhase) => { const query = "INSERT INTO video_phase VALUES ($1, $2) " + "RETURNING *"; // returns inserted row const params = [videoPhase.videoId, videoPhase.phaseId]; return db.query(query, params); }; const findAllByVideoId = (videoId) => { const query = "SELECT * FROM video_phase WHERE video_id=$1"; return db.query(query, [videoId]); }; const findAllByPhaseId = (phaseId) => { const query = "SELECT * FROM video_phase WHERE phase_id=$1"; return db.query(query, [phaseId]); }; const find = (videoId, phaseId) => { const query = "SELECT * FROM video_phase WHERE video_id=$1 AND phase_id=$2"; const params = [videoId, phaseId]; return db.query(query, params); }; const removeByVideoId = (videoId) => { const query = "DELETE FROM video_phase WHERE video_id = $1 RETURNING *"; return db.query(query, [videoId]); }; const removeByPhaseId = (phaseId) => { const query = "DELETE FROM video_phase WHERE phase_id = $1 RETURNING *"; return db.query(query, [phaseId]); }; module.exports = { insert, findAllByVideoId, findAllByPhaseId, find, removeByVideoId, removeByPhaseId, }; |