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 | 2x 2x 2x 2x 2x 2x 1x 1x 2x 1x 1x 1x 2x | const db = require("../../database/connection");
const insert = (information) => {
const query = "INSERT INTO information(type, content) VALUES ($1, $2) " +
"RETURNING *"; // returns passed information entry with its id set to corresponding id in database
const params = [information.type, information.content];
return db.query(query, params);
};
const findByType = (type) => {
const query = "SELECT * FROM information WHERE type=$1";
return db.query(query, [type]);
};
const update = (information) => {
const query =
"UPDATE information SET content = $2 WHERE type=$1 RETURNING *";
// returns passed information
const params = [information.type, information.content];
return db.query(query, params);
};
module.exports = {
insert,
findByType,
update,
};
|