adding charges table and starting the endpoint for charging for a grant
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
module.exports = models => {
|
||||
const { Donor, Grant, Cause, Region, Organization } = models;
|
||||
const { Donor, Grant, Cause, Region, Organization, Charge } = models;
|
||||
|
||||
Donor.hasMany(Grant, { foreignKey: 'donor_id' });
|
||||
|
||||
@@ -20,4 +20,12 @@ module.exports = models => {
|
||||
foreignKey: 'grant_id',
|
||||
otherKey: 'organization_id'
|
||||
});
|
||||
|
||||
Donor.hasMany(Charge, {
|
||||
foreignKey: 'user_id'
|
||||
});
|
||||
|
||||
Organization.hasMany(Charge, {
|
||||
foreignKey: 'user_id'
|
||||
});
|
||||
};
|
||||
|
||||
@@ -2,11 +2,11 @@ require('dotenv/config');
|
||||
|
||||
module.exports = {
|
||||
development: {
|
||||
username: process.env.DB_USERNAME,
|
||||
password: process.env.DB_PASSWORD,
|
||||
database: process.env.DB_DB,
|
||||
host: process.env.DB_HOST,
|
||||
dialect: process.env.DB_DIALECT
|
||||
username: 'root',
|
||||
password: 'water',
|
||||
database: 'base',
|
||||
host: 'localhost',
|
||||
dialect: 'mysql'
|
||||
},
|
||||
test: {
|
||||
username: 'root',
|
||||
|
||||
@@ -5,7 +5,8 @@ const Sequelize = require('sequelize'),
|
||||
RegionModel = require('../models/region.model.js'),
|
||||
OrganizationModel = require('../models/organization.model.js'),
|
||||
UserModel = require('../models/user.model.js'),
|
||||
associate = require('./associate');
|
||||
ChargeModel = require('../models/charge.model');
|
||||
associate = require('./associate');
|
||||
|
||||
const connection_uri = process.env.JAWSDB_MARIA_URL;
|
||||
|
||||
@@ -40,12 +41,14 @@ const Cause = CauseModel(sequelize, Sequelize);
|
||||
const Region = RegionModel(sequelize, Sequelize);
|
||||
const Organization = OrganizationModel(sequelize, Sequelize);
|
||||
const User = UserModel(sequelize, Sequelize);
|
||||
const Charge = ChargeModel(sequelize, Sequelize);
|
||||
db.Donor = Donor;
|
||||
db.Grant = Grant;
|
||||
db.Cause = Cause;
|
||||
db.Region = Region;
|
||||
db.Organization = Organization;
|
||||
db.User = User;
|
||||
db.Charge = Charge;
|
||||
|
||||
// make associations with created models
|
||||
associate(db);
|
||||
|
||||
Reference in New Issue
Block a user