Skip to content

Commit

Permalink
Organizing database query files
Browse files Browse the repository at this point in the history
relates #24
  • Loading branch information
MohammedAlghazali committed Mar 30, 2020
1 parent 70a78ac commit ab11298
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 11 deletions.
2 changes: 1 addition & 1 deletion server/controllers/routes/admin/cohort/deleteCohort.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const deleteCohort = require('../../../../database/queries/cohort/deleteCohort');
const { deleteCohort } = require('../../../../database/queries');

const cohortDelete = async (req, res, next) => {
try {
Expand Down
4 changes: 2 additions & 2 deletions server/controllers/routes/admin/index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const router = require('express').Router();
const { cohortDelete } = require('./cohort');
const { cohortAdd, validateAddProject } = require('./project');
const { projectAdd, validateAddProject } = require('./project');

router
.route('/cohorts/:cohortId')
Expand All @@ -20,6 +20,6 @@ router
})
.delete(cohortDelete);

router.post('/projects', validateAddProject, cohortAdd);
router.post('/projects', validateAddProject, projectAdd);

module.exports = router;
6 changes: 3 additions & 3 deletions server/controllers/routes/admin/project/addProject.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const addProject = require('../../../../database/queries/project/addProject');
const { addProject } = require('../../../../database/queries');

const cohortAdd = async (req, res, next) => {
const projectAdd = async (req, res, next) => {
try {
const {
name,
Expand Down Expand Up @@ -30,5 +30,5 @@ const cohortAdd = async (req, res, next) => {
};

module.exports = {
cohortAdd,
projectAdd,
};
4 changes: 2 additions & 2 deletions server/controllers/routes/admin/project/index.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const { cohortAdd } = require('./addProject');
const { projectAdd } = require('./addProject');
const validateAddProject = require('./validateAddProject');

module.exports = {
cohortAdd,
projectAdd,
validateAddProject,
};
2 changes: 1 addition & 1 deletion server/database/queries/cohort/deleteCohort.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@ const connection = require('../../config/connection');
const deleteCohort = (cohortId) =>
connection.query('DELETE FROM cohort WHERE id = $1', [cohortId]);

module.exports = deleteCohort;
module.exports = { deleteCohort };
5 changes: 5 additions & 0 deletions server/database/queries/cohort/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { deleteCohort } = require('./deleteCohort');

module.exports = {
deleteCohort,
};
7 changes: 7 additions & 0 deletions server/database/queries/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
const { deleteCohort } = require('./cohort');
const { addProject } = require('./project');

module.exports = {
deleteCohort,
addProject,
};
4 changes: 2 additions & 2 deletions server/database/queries/project/addProject.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
const connection = require('../../config/connection');

const addCohort = (
const addProject = (
name,
description,
imgUrl,
Expand All @@ -14,4 +14,4 @@ const addCohort = (
[name, description, imgUrl, githubLink, websiteLink, projectType, cohortId],
);

module.exports = addCohort;
module.exports = { addProject };
5 changes: 5 additions & 0 deletions server/database/queries/project/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
const { addProject } = require('./addProject');

module.exports = {
addProject,
};

0 comments on commit ab11298

Please sign in to comment.