From 797ec00ec3cce714aafd73e7d67a5b0f7339a64c Mon Sep 17 00:00:00 2001 From: Bonnie Schulkin Date: Thu, 29 Mar 2018 16:14:56 -0700 Subject: [PATCH] Bonnie code review comments --- src/model/helpers.js | 2 ++ src/model/queries.js | 7 +++---- test/queries.test.js | 1 + 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/model/helpers.js b/src/model/helpers.js index fbd6777..48612f8 100644 --- a/src/model/helpers.js +++ b/src/model/helpers.js @@ -1,5 +1,7 @@ const db = require('./db'); +// if it's for tests only, put it in the tests folder + const clearAllDragons = () => { return db.oneOrNone(` TRUNCATE dragons RESTART IDENTITY;`); diff --git a/src/model/queries.js b/src/model/queries.js index 5c0bc10..6a73cf1 100644 --- a/src/model/queries.js +++ b/src/model/queries.js @@ -9,22 +9,21 @@ const db = require('./db'); * @param {number} maxhp * @param {number} strength * @param {number} defense -* @param {string} imageUrl +* @param {string} imageurl * @returns {promise} - Promise that resolves to an object * representing the row added to the posts table. */ - const createDragon = (type, level, currenthp, maxhp, strength, defense, imageurl) => { const query = ` INSERT INTO dragons (type, level, currenthp, maxhp, strength, defense, imageurl) VALUES - ($1, $2, $3, $4, $5, $6, $7) + ($/type/, $/level/, $/currenthp/, $/maxhp/, $/strength/, $/defense/, $/imageurl/) RETURNING * `; - return db.one(query, [type, level, currenthp, maxhp, strength, defense, imageurl]); + return db.one(query, args); }; /** diff --git a/test/queries.test.js b/test/queries.test.js index c90bd53..612f22f 100644 --- a/test/queries.test.js +++ b/test/queries.test.js @@ -6,6 +6,7 @@ const queries = require('../src/model/queries'); const helpers = require('../src/model/helpers'); /* global define, it, describe, before, beforeEach */ +// TODO: DRY this out const databaseReset = function () { return helpers.clearAllData() .then(() => {