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 45 | 2x 2x 7x 7x 7x 2x 3x 3x 2x 2x 2x 2x 1x 1x 1x 2x 1x 1x 2x 1x 1x 2x | const db = require("../../database/connection"); const insert = (faq) => { const query = "INSERT INTO faq(question, answer) VALUES ($1, $2) " + "RETURNING *"; // returns passed faq with it's id set to corresponding id in database const params = [faq.question, faq.answer]; return db.query(query, params); }; const findById = (id) => { const query = "SELECT * FROM faq WHERE id=$1"; return db.query(query, [id]); }; const findAll = () => { const query = "SELECT * FROM faq"; return db.query(query); }; const update = (faq) => { const query = "UPDATE faq SET question = $2, answer = $3 WHERE id = $1" + "RETURNING *"; // returns passed faq with it's id set to corresponding id in database const params = [faq.id, faq.question, faq.answer]; return db.query(query, params); }; const removeById = (id) => { const query = "DELETE FROM faq WHERE id=$1 RETURNING *"; return db.query(query, [id]); }; const findByKeyword = (keyword) => { const query = "SELECT * FROM faq WHERE UPPER(question) LIKE UPPER($1)"; return db.query(query, [`%${keyword}%`]); }; module.exports = { insert, findById, findAll, findByKeyword, update, removeById, }; |