Files
Ucharify_api/models/Grant.js
T
2019-03-16 22:41:57 -07:00

43 lines
794 B
JavaScript

module.exports = (sequelize, DataTypes) => {
const Grant = sequelize.define('Grant', {
id: {
type: DataTypes.INTEGER,
primaryKey: true,
autoIncrement: true
},
name: {
type: DataTypes.STRING,
allowNull: false
},
amount: {
type: DataTypes.INTEGER,
allowNull: false
},
monthly: {
type: DataTypes.BOOLEAN,
allowNull: false,
defaultValue: false
},
num_causes: {
type: DataTypes.INTEGER,
allowNull: false
},
num_regions: {
type: DataTypes.INTEGER,
allowNull: false
}
});
Grant.associate = models => {
Grant.belongsToMany(models.Organization, {
through: 'grants_organizations',
foreignKey: 'grant_id',
otherKey: 'organization_id'
});
Grant.hasMany(models.Charge, { foreignKey: 'grant_id' });
};
return Grant;
};