Skip to content

Commit

Permalink
Created model queries outlines
Browse files Browse the repository at this point in the history
related to #19
  • Loading branch information
Armand-Lluka committed Sep 13, 2018
1 parent a12d101 commit c734ffe
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/model/acceptChallenge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// Accepted Challenges
1 change: 1 addition & 0 deletions src/model/completeChallenge.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// completeChallenges
1 change: 1 addition & 0 deletions src/model/getAcceptedChallenges.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// getAccepetedChallenges
12 changes: 12 additions & 0 deletions src/model/getChallenges.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
const dbConnection = require('../../db/db_connection');

module.exports = () =>
new Promise((resolve,reject) => {
dbConnection.query(
`SELECT * FROM challenges`,
(err,res) =>{
if (err) return reject(err);
resolve(res);
}
)
});
1 change: 1 addition & 0 deletions src/model/getCompletedChallenges.js
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
// getCompletedChalllenges
15 changes: 14 additions & 1 deletion src/model/index.js
Original file line number Diff line number Diff line change
@@ -1 +1,14 @@
// booo index.js
// booo index.js
const acceptChallenge = require('./acceptChallenge')
const completeChallenge = require('./completeChallenge')
const getAcceptedChallenges = require('./getAcceptedChallenges')
const getChallenges = require('./getChallenges')
const getCompletedChallenges = require ('./getCompletedChallenges')

module.exports = {
acceptChallenge,
completeChallenge,
getAcceptedChallenges,
getChallenges,
getCompletedChallenges
}
1 change: 0 additions & 1 deletion test/queries.js

This file was deleted.

10 changes: 10 additions & 0 deletions test/queries.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
// go tests
const dbConnection = require('../db/db_connection');
const challengeDetails = require('../src/model/challengeDetail')

describe('Can select all from challenges', done =>{
dbConnection().then(
challengeDetails
)
})

0 comments on commit c734ffe

Please sign in to comment.