Skip to content

Commit

Permalink
make query to add project data in project table
Browse files Browse the repository at this point in the history
relates #24
  • Loading branch information
MohammedAlghazali committed Mar 30, 2020
1 parent fa8c6f0 commit f8b4264
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 0 deletions.
3 changes: 3 additions & 0 deletions server/controllers/routes/admin/index.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
const router = require('express').Router();
const { cohortDelete } = require('./cohort');
const { cohortAdd, validateAddProject } = require('./project');

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

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

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

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

const addCohort = (
name,
description,
imgUrl,
githubLink,
websiteLink,
projectType,
cohortId,
) =>
connection.query(
'INSERT INTO project (name, description, img_url, github_link, website_link, project_type, cohort_id) VALUES ($1, $2, $3, $4, $5, $6, $7)',
[name, description, imgUrl, githubLink, websiteLink, projectType, cohortId],
);

module.exports = addCohort;

0 comments on commit f8b4264

Please sign in to comment.