Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/model/helpers.js
Original file line number Diff line number Diff line change
@@ -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;`);
Expand Down
7 changes: 3 additions & 4 deletions src/model/queries.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
};

/**
Expand Down
1 change: 1 addition & 0 deletions test/queries.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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(() => {
Expand Down