associations and adding more routes and structure

This commit is contained in:
Arjun Patel
2019-01-15 22:08:54 -08:00
parent b453c78c00
commit a4e4394329
11 changed files with 100 additions and 19 deletions
+1 -1
View File
@@ -3,7 +3,7 @@ const db = require('../config/db.config.js'),
jwt = require('jsonwebtoken'),
errorMaker = require('../helpers/error.maker');
const Donors = db.donors;
const Donors = db.Donors;
// Find a Donor by email + login with JWT
exports.login = (req, res, next) => {
@@ -1,8 +1,8 @@
const db = require('../config/db.config.js'),
const db = require('../../config/db.config.js'),
bcrypt = require('bcrypt-nodejs'),
errorMaker = require('../helpers/error.maker');
errorMaker = require('../../helpers/error.maker');
const Donors = db.donors;
const Donors = db.Donors;
// Create/post a Donor
exports.create = (req, res, next) => {
@@ -0,0 +1,31 @@
const db = require('../../config/db.config.js'),
errorMaker = require('../../helpers/error.maker');
const Grants = db.Grants;
// Create a grant for certain donor
exports.create = (req, res, next) => {
const donor_id = req.params.donor_id;
const { name, amount, causes, regions, organizations } = req.body;
Grants.create({
name,
amount
});
};
// Find grants with cause and region and charity details by Id
exports.findByDonorId = (req, res, next) => {
Grants.findAll({
where: {
donor_id: req.params.donor_id
}
})
.then(grants => {
res.status(200).json({
grants,
number_grants: grants.length
});
})
.catch(error => next(error));
};