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
@@ -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));
};