commit
This commit is contained in:
parent
afc5217d0a
commit
7d70b0bfb5
4 changed files with 100 additions and 1 deletions
|
@ -30,7 +30,7 @@ function getGames(connection) {
|
|||
function getGame(connection, gameid) {
|
||||
return new Promise((resolve, reject) => {
|
||||
connection.query(
|
||||
`SELECT * FROM games WHERE id = "${gameid}"`,
|
||||
`SELECT * FROM games WHERE id = ${gameid}`,
|
||||
(error, result) => {
|
||||
if (error) {
|
||||
reject(new Error(error));
|
||||
|
@ -41,6 +41,25 @@ function getGame(connection, gameid) {
|
|||
})
|
||||
}
|
||||
|
||||
function addGame(connection, id, title, subtitle, edition, type, players, duration, ages, languages, universe, ranges, categories, themes, mecanisms, editor, authors, illustrators) {
|
||||
console.log(`INSERT INTO games (id, title, subtitle, edition, type, players, duration, ages, languages, universe, ranges, categories, themes, mecanisms, editor, authors, illustrators) VALUES (${id}, "${title}", "${subtitle}", ${edition}, "${type}", "${players}", "${duration}", "${ages}", "${languages}", "${universe}", "${ranges}", "${categories}", "${themes}", "${mecanisms}", "${editor}", "${authors}", "${illustrators}")`)
|
||||
return new Promise((resolve, reject) => {
|
||||
connection.query(
|
||||
`INSERT INTO games (id, title, subtitle, edition, type, players, duration, ages, languages, universe, ranges, categories, themes, mecanisms, editor, authors, illustrators) VALUES (${id}, "${title}", "${subtitle}", ${edition}, "${type}", "${players}", "${duration}", "${ages}", "${languages}", "${universe}", "${ranges}", "${categories}", "${themes}", "${mecanisms}", "${editor}", "${authors}", "${illustrators}")`,
|
||||
(error, result) => {
|
||||
if (error) {
|
||||
reject(new Error(error));
|
||||
}
|
||||
resolve(result);
|
||||
}
|
||||
)
|
||||
})
|
||||
}
|
||||
|
||||
// +-----------------------------------+
|
||||
// | HELPERS |
|
||||
// +-----------------------------------+
|
||||
|
||||
function addHelper(connection, game_id, user_id) {
|
||||
return new Promise((resolve, reject) => {
|
||||
connection.query(
|
||||
|
@ -148,6 +167,8 @@ module.exports = {
|
|||
|
||||
getGames,
|
||||
getGame,
|
||||
addGame,
|
||||
|
||||
addHelper,
|
||||
removeHelper,
|
||||
getHelpers,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue