making needed changes to make the table names strict
This commit is contained in:
@@ -125,7 +125,7 @@ exports.getGrantsByDonorId = async (req, res, next) => {
|
|||||||
JSON_ARRAYAGG(o.primary_cause) AS causes,
|
JSON_ARRAYAGG(o.primary_cause) AS causes,
|
||||||
JSON_ARRAYAGG(o.primary_region) AS regions
|
JSON_ARRAYAGG(o.primary_region) AS regions
|
||||||
from grants as g
|
from grants as g
|
||||||
inner join GrantOrganizations as go on go.grant_id = g.id
|
inner join grants_organizations as go on go.grant_id = g.id
|
||||||
left join organizations as o on o.id = go.organization_id
|
left join organizations as o on o.id = go.organization_id
|
||||||
where donor_id = :donor_id
|
where donor_id = :donor_id
|
||||||
group by g.id, g.name, g.amount, g.monthly, g.num_causes, g.num_regions, g.donor_id;
|
group by g.id, g.name, g.amount, g.monthly, g.num_causes, g.num_regions, g.donor_id;
|
||||||
|
|||||||
+16
-7
@@ -1,11 +1,20 @@
|
|||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const Cause = sequelize.define('Cause', {
|
const Cause = sequelize.define(
|
||||||
id: {
|
'Cause',
|
||||||
type: DataTypes.INTEGER,
|
{
|
||||||
primaryKey: true,
|
id: {
|
||||||
autoIncrement: true
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true
|
||||||
|
},
|
||||||
|
name: { type: DataTypes.STRING, allowNull: false, unique: true }
|
||||||
},
|
},
|
||||||
name: { type: DataTypes.STRING, allowNull: false, unique: true }
|
{
|
||||||
});
|
freezeTableName: true,
|
||||||
|
|
||||||
|
// define the table's name
|
||||||
|
tableName: 'causes'
|
||||||
|
}
|
||||||
|
);
|
||||||
return Cause;
|
return Cause;
|
||||||
};
|
};
|
||||||
|
|||||||
+20
-11
@@ -2,20 +2,29 @@
|
|||||||
const PaymentStatus = require('./PaymentStatus');
|
const PaymentStatus = require('./PaymentStatus');
|
||||||
|
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const Charge = sequelize.define('Charge', {
|
const Charge = sequelize.define(
|
||||||
id: { type: DataTypes.UUID, primaryKey: true, allowNull: false },
|
'Charge',
|
||||||
description: DataTypes.STRING,
|
{
|
||||||
amount: DataTypes.INTEGER,
|
id: { type: DataTypes.UUID, primaryKey: true, allowNull: false },
|
||||||
|
description: DataTypes.STRING,
|
||||||
|
amount: DataTypes.INTEGER,
|
||||||
|
|
||||||
payment_status: {
|
payment_status: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
references: {
|
references: {
|
||||||
model: PaymentStatus(sequelize, DataTypes),
|
model: PaymentStatus(sequelize, DataTypes),
|
||||||
key: 'name'
|
key: 'name'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
freezeTableName: true,
|
||||||
|
|
||||||
|
// define the table's name
|
||||||
|
tableName: 'charges'
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
return Charge;
|
return Charge;
|
||||||
};
|
};
|
||||||
|
|||||||
+52
-43
@@ -1,49 +1,58 @@
|
|||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const Donor = sequelize.define('Donor', {
|
const Donor = sequelize.define(
|
||||||
id: {
|
'Donor',
|
||||||
type: DataTypes.UUID,
|
{
|
||||||
allowNull: false,
|
id: {
|
||||||
primaryKey: true
|
type: DataTypes.UUID,
|
||||||
},
|
allowNull: false,
|
||||||
stripe_id: {
|
primaryKey: true
|
||||||
type: DataTypes.UUID,
|
|
||||||
defaultValue: null,
|
|
||||||
unique: true
|
|
||||||
},
|
|
||||||
subscription_id: {
|
|
||||||
type: DataTypes.UUID,
|
|
||||||
defaultValue: null,
|
|
||||||
unique: true
|
|
||||||
},
|
|
||||||
first_name: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
last_name: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
email: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
validate: {
|
|
||||||
isEmail: true
|
|
||||||
},
|
},
|
||||||
allowNull: false,
|
stripe_id: {
|
||||||
unique: true
|
type: DataTypes.UUID,
|
||||||
},
|
defaultValue: null,
|
||||||
password: {
|
unique: true
|
||||||
type: DataTypes.STRING,
|
},
|
||||||
allowNull: false
|
subscription_id: {
|
||||||
},
|
type: DataTypes.UUID,
|
||||||
age: DataTypes.INTEGER,
|
defaultValue: null,
|
||||||
phone: DataTypes.STRING(20),
|
unique: true
|
||||||
|
},
|
||||||
|
first_name: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
last_name: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
email: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
validate: {
|
||||||
|
isEmail: true
|
||||||
|
},
|
||||||
|
allowNull: false,
|
||||||
|
unique: true
|
||||||
|
},
|
||||||
|
password: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
age: DataTypes.INTEGER,
|
||||||
|
phone: DataTypes.STRING(20),
|
||||||
|
|
||||||
address: DataTypes.STRING,
|
address: DataTypes.STRING,
|
||||||
city: DataTypes.STRING,
|
city: DataTypes.STRING,
|
||||||
state: DataTypes.STRING,
|
state: DataTypes.STRING,
|
||||||
zip: DataTypes.STRING(10),
|
zip: DataTypes.STRING(10),
|
||||||
country: DataTypes.STRING
|
country: DataTypes.STRING
|
||||||
});
|
},
|
||||||
|
{
|
||||||
|
freezeTableName: true,
|
||||||
|
|
||||||
|
// define the table's name
|
||||||
|
tableName: 'donors'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
return Donor;
|
return Donor;
|
||||||
};
|
};
|
||||||
|
|||||||
+43
-34
@@ -1,43 +1,52 @@
|
|||||||
const Donor = require('./Donor');
|
const Donor = require('./Donor');
|
||||||
|
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const Grant = sequelize.define('Grant', {
|
const Grant = sequelize.define(
|
||||||
id: {
|
'Grant',
|
||||||
type: DataTypes.INTEGER,
|
{
|
||||||
primaryKey: true,
|
id: {
|
||||||
autoIncrement: true
|
type: DataTypes.INTEGER,
|
||||||
},
|
primaryKey: true,
|
||||||
name: {
|
autoIncrement: true
|
||||||
type: DataTypes.STRING,
|
},
|
||||||
allowNull: false
|
name: {
|
||||||
},
|
type: DataTypes.STRING,
|
||||||
amount: {
|
allowNull: false
|
||||||
type: DataTypes.INTEGER,
|
},
|
||||||
allowNull: false
|
amount: {
|
||||||
},
|
type: DataTypes.INTEGER,
|
||||||
monthly: {
|
allowNull: false
|
||||||
type: DataTypes.BOOLEAN,
|
},
|
||||||
allowNull: false,
|
monthly: {
|
||||||
defaultValue: false
|
type: DataTypes.BOOLEAN,
|
||||||
},
|
allowNull: false,
|
||||||
num_causes: {
|
defaultValue: false
|
||||||
type: DataTypes.INTEGER,
|
},
|
||||||
allowNull: false
|
num_causes: {
|
||||||
},
|
type: DataTypes.INTEGER,
|
||||||
num_regions: {
|
allowNull: false
|
||||||
type: DataTypes.INTEGER,
|
},
|
||||||
allowNull: false
|
num_regions: {
|
||||||
},
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
|
||||||
donor_id: {
|
donor_id: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
references: {
|
references: {
|
||||||
model: Donor(sequelize, DataTypes),
|
model: Donor(sequelize, DataTypes),
|
||||||
key: 'id'
|
key: 'id'
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
freezeTableName: true,
|
||||||
|
|
||||||
|
// define the table's name
|
||||||
|
tableName: 'grants'
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
Grant.associate = models => {
|
Grant.associate = models => {
|
||||||
Grant.hasMany(models.Charge, { foreignKey: 'grant_id' });
|
Grant.hasMany(models.Charge, { foreignKey: 'grant_id' });
|
||||||
|
|||||||
@@ -2,32 +2,41 @@ const Organization = require('./Organization'),
|
|||||||
Grant = require('./Grant');
|
Grant = require('./Grant');
|
||||||
|
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const GrantOrganization = sequelize.define('GrantOrganization', {
|
const GrantOrganization = sequelize.define(
|
||||||
id: {
|
'GrantOrganization',
|
||||||
type: DataTypes.INTEGER,
|
{
|
||||||
primaryKey: true,
|
id: {
|
||||||
autoIncrement: true
|
type: DataTypes.INTEGER,
|
||||||
},
|
primaryKey: true,
|
||||||
grant_id: {
|
autoIncrement: true
|
||||||
type: DataTypes.INTEGER,
|
},
|
||||||
allowNull: false,
|
grant_id: {
|
||||||
references: {
|
type: DataTypes.INTEGER,
|
||||||
model: Grant(sequelize, DataTypes),
|
allowNull: false,
|
||||||
key: 'id'
|
references: {
|
||||||
|
model: Grant(sequelize, DataTypes),
|
||||||
|
key: 'id'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
organization_id: {
|
||||||
|
type: DataTypes.UUID,
|
||||||
|
allowNull: false,
|
||||||
|
references: {
|
||||||
|
model: Organization(sequelize, DataTypes),
|
||||||
|
key: 'id'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
amount: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
allowNull: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
organization_id: {
|
{
|
||||||
type: DataTypes.UUID,
|
freezeTableName: true,
|
||||||
allowNull: false,
|
|
||||||
references: {
|
// define the table's name
|
||||||
model: Organization(sequelize, DataTypes),
|
tableName: 'grants_organizations'
|
||||||
key: 'id'
|
|
||||||
}
|
|
||||||
},
|
|
||||||
amount: {
|
|
||||||
type: DataTypes.INTEGER,
|
|
||||||
allowNull: false
|
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
return GrantOrganization;
|
return GrantOrganization;
|
||||||
};
|
};
|
||||||
|
|||||||
+118
-109
@@ -2,121 +2,130 @@ const Cause = require('./Cause'),
|
|||||||
Region = require('./Region');
|
Region = require('./Region');
|
||||||
|
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const Organization = sequelize.define('Organization', {
|
const Organization = sequelize.define(
|
||||||
id: {
|
'Organization',
|
||||||
type: DataTypes.UUID,
|
{
|
||||||
allowNull: false,
|
id: {
|
||||||
primaryKey: true
|
type: DataTypes.UUID,
|
||||||
},
|
allowNull: false,
|
||||||
name: { type: DataTypes.STRING, allowNull: false },
|
primaryKey: true
|
||||||
profile_pic_url: {
|
},
|
||||||
type: DataTypes.STRING,
|
name: { type: DataTypes.STRING, allowNull: false },
|
||||||
allowNull: true
|
profile_pic_url: {
|
||||||
},
|
type: DataTypes.STRING,
|
||||||
short_description: { type: DataTypes.STRING, allowNull: false },
|
allowNull: true
|
||||||
total_received: {
|
},
|
||||||
type: DataTypes.INTEGER,
|
short_description: { type: DataTypes.STRING, allowNull: false },
|
||||||
defaultValue: 0
|
total_received: {
|
||||||
},
|
type: DataTypes.INTEGER,
|
||||||
total_donors: {
|
defaultValue: 0
|
||||||
type: DataTypes.INTEGER,
|
},
|
||||||
defaultValue: 0
|
total_donors: {
|
||||||
},
|
type: DataTypes.INTEGER,
|
||||||
stripe_account_id: {
|
defaultValue: 0
|
||||||
type: DataTypes.UUID,
|
},
|
||||||
defaultValue: null
|
stripe_account_id: {
|
||||||
},
|
type: DataTypes.UUID,
|
||||||
|
defaultValue: null
|
||||||
primary_contact_email: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
validate: {
|
|
||||||
isEmail: true
|
|
||||||
},
|
},
|
||||||
allowNull: false,
|
|
||||||
unique: true
|
|
||||||
},
|
|
||||||
password: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
|
|
||||||
address: {
|
primary_contact_email: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
allowNull: false
|
validate: {
|
||||||
},
|
isEmail: true
|
||||||
city: {
|
},
|
||||||
type: DataTypes.STRING,
|
allowNull: false,
|
||||||
allowNull: false
|
unique: true
|
||||||
},
|
},
|
||||||
state: {
|
password: {
|
||||||
type: DataTypes.STRING(5),
|
type: DataTypes.STRING,
|
||||||
allowNull: false
|
allowNull: false
|
||||||
},
|
},
|
||||||
country: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
defaultValue: 'USA',
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
zip: {
|
|
||||||
type: DataTypes.STRING(10),
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
|
|
||||||
primary_cause: {
|
address: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING,
|
||||||
allowNull: false,
|
allowNull: false
|
||||||
references: {
|
},
|
||||||
model: Cause(sequelize, DataTypes),
|
city: {
|
||||||
key: 'name'
|
type: DataTypes.STRING,
|
||||||
}
|
allowNull: false
|
||||||
},
|
},
|
||||||
primary_region: {
|
state: {
|
||||||
type: DataTypes.STRING,
|
type: DataTypes.STRING(5),
|
||||||
allowNull: false,
|
allowNull: false
|
||||||
references: {
|
},
|
||||||
model: Region(sequelize, DataTypes),
|
country: {
|
||||||
key: 'name'
|
type: DataTypes.STRING,
|
||||||
|
defaultValue: 'USA',
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
zip: {
|
||||||
|
type: DataTypes.STRING(10),
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
|
||||||
|
primary_cause: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
references: {
|
||||||
|
model: Cause(sequelize, DataTypes),
|
||||||
|
key: 'name'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
primary_region: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false,
|
||||||
|
references: {
|
||||||
|
model: Region(sequelize, DataTypes),
|
||||||
|
key: 'name'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
|
||||||
|
total_rating: { type: DataTypes.INTEGER, defaultValue: 0 },
|
||||||
|
|
||||||
|
ein: {
|
||||||
|
type: DataTypes.STRING(10),
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
estimate_asset_value: {
|
||||||
|
type: DataTypes.BIGINT,
|
||||||
|
defaultValue: 0
|
||||||
|
},
|
||||||
|
estimate_yearly_operating_cost: {
|
||||||
|
type: DataTypes.BIGINT,
|
||||||
|
defaultValue: 0
|
||||||
|
},
|
||||||
|
|
||||||
|
is_nonprofit: {
|
||||||
|
type: DataTypes.BOOLEAN,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: false
|
||||||
|
},
|
||||||
|
is_verified: {
|
||||||
|
type: DataTypes.BOOLEAN,
|
||||||
|
allowNull: false,
|
||||||
|
defaultValue: false
|
||||||
|
},
|
||||||
|
|
||||||
|
primary_contact_phone: {
|
||||||
|
type: DataTypes.STRING(20),
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
primary_contact_first_name: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false
|
||||||
|
},
|
||||||
|
primary_contact_last_name: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
allowNull: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
freezeTableName: true,
|
||||||
|
|
||||||
total_rating: { type: DataTypes.INTEGER, defaultValue: 0 },
|
// define the table's name
|
||||||
|
tableName: 'organizations'
|
||||||
ein: {
|
|
||||||
type: DataTypes.STRING(10),
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
estimate_asset_value: {
|
|
||||||
type: DataTypes.BIGINT,
|
|
||||||
defaultValue: 0
|
|
||||||
},
|
|
||||||
estimate_yearly_operating_cost: {
|
|
||||||
type: DataTypes.BIGINT,
|
|
||||||
defaultValue: 0
|
|
||||||
},
|
|
||||||
|
|
||||||
is_nonprofit: {
|
|
||||||
type: DataTypes.BOOLEAN,
|
|
||||||
allowNull: false,
|
|
||||||
defaultValue: false
|
|
||||||
},
|
|
||||||
is_verified: {
|
|
||||||
type: DataTypes.BOOLEAN,
|
|
||||||
allowNull: false,
|
|
||||||
defaultValue: false
|
|
||||||
},
|
|
||||||
|
|
||||||
primary_contact_phone: {
|
|
||||||
type: DataTypes.STRING(20),
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
primary_contact_first_name: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false
|
|
||||||
},
|
|
||||||
primary_contact_last_name: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
allowNull: false
|
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
return Organization;
|
return Organization;
|
||||||
};
|
};
|
||||||
|
|||||||
+18
-9
@@ -1,12 +1,21 @@
|
|||||||
"use strict";
|
'use strict';
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const PaymentStatus = sequelize.define("PaymentStatus", {
|
const PaymentStatus = sequelize.define(
|
||||||
name: {
|
'PaymentStatus',
|
||||||
type: DataTypes.STRING,
|
{
|
||||||
primaryKey: true,
|
name: {
|
||||||
allowNull: false
|
type: DataTypes.STRING,
|
||||||
}
|
primaryKey: true,
|
||||||
});
|
allowNull: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
freezeTableName: true,
|
||||||
|
|
||||||
return PaymentStatus;
|
// define the table's name
|
||||||
|
tableName: 'paymentstatuses'
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
|
return PaymentStatus;
|
||||||
};
|
};
|
||||||
|
|||||||
+29
-20
@@ -1,28 +1,37 @@
|
|||||||
const Organization = require('./Organization');
|
const Organization = require('./Organization');
|
||||||
|
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const Post = sequelize.define('Post', {
|
const Post = sequelize.define(
|
||||||
id: {
|
'Post',
|
||||||
type: DataTypes.INTEGER,
|
{
|
||||||
primaryKey: true,
|
id: {
|
||||||
autoIncrement: true
|
type: DataTypes.INTEGER,
|
||||||
},
|
primaryKey: true,
|
||||||
text: {
|
autoIncrement: true
|
||||||
type: DataTypes.STRING(350),
|
},
|
||||||
allowNull: false
|
text: {
|
||||||
},
|
type: DataTypes.STRING(350),
|
||||||
organization_id: {
|
allowNull: false
|
||||||
type: DataTypes.UUID,
|
},
|
||||||
allowNull: false,
|
organization_id: {
|
||||||
references: {
|
type: DataTypes.UUID,
|
||||||
model: Organization(sequelize, DataTypes),
|
allowNull: false,
|
||||||
key: 'id'
|
references: {
|
||||||
|
model: Organization(sequelize, DataTypes),
|
||||||
|
key: 'id'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
num_ribbons: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
defaultValue: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
num_ribbons: {
|
{
|
||||||
type: DataTypes.INTEGER,
|
freezeTableName: true,
|
||||||
defaultValue: 0
|
|
||||||
|
// define the table's name
|
||||||
|
tableName: 'posts'
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
return Post;
|
return Post;
|
||||||
};
|
};
|
||||||
|
|||||||
+58
-49
@@ -5,60 +5,69 @@ const Organization = require('./Organization'),
|
|||||||
Region = require('./Region');
|
Region = require('./Region');
|
||||||
|
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const Project = sequelize.define('Project', {
|
const Project = sequelize.define(
|
||||||
id: {
|
'Project',
|
||||||
type: DataTypes.INTEGER,
|
{
|
||||||
primaryKey: true,
|
id: {
|
||||||
autoIncrement: true
|
type: DataTypes.INTEGER,
|
||||||
},
|
primaryKey: true,
|
||||||
total_received: {
|
autoIncrement: true
|
||||||
type: DataTypes.INTEGER,
|
},
|
||||||
defaultValue: 0
|
total_received: {
|
||||||
},
|
type: DataTypes.INTEGER,
|
||||||
total_donors: {
|
defaultValue: 0
|
||||||
type: DataTypes.INTEGER,
|
},
|
||||||
defaultValue: 0
|
total_donors: {
|
||||||
},
|
type: DataTypes.INTEGER,
|
||||||
|
defaultValue: 0
|
||||||
|
},
|
||||||
|
|
||||||
title: {
|
title: {
|
||||||
type: DataTypes.STRING(1000),
|
type: DataTypes.STRING(1000),
|
||||||
allowNull: false
|
allowNull: false
|
||||||
},
|
},
|
||||||
description: DataTypes.STRING,
|
description: DataTypes.STRING,
|
||||||
isComplete: {
|
isComplete: {
|
||||||
type: DataTypes.BOOLEAN,
|
type: DataTypes.BOOLEAN,
|
||||||
defaultValue: false
|
defaultValue: false
|
||||||
},
|
},
|
||||||
|
|
||||||
// cause: {
|
// cause: {
|
||||||
// type: DataTypes.STRING,
|
// type: DataTypes.STRING,
|
||||||
// allowNull: false,
|
// allowNull: false,
|
||||||
// references: {
|
// references: {
|
||||||
// model: Cause(sequelize, DataTypes),
|
// model: Cause(sequelize, DataTypes),
|
||||||
// key: 'name'
|
// key: 'name'
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
// region: {
|
// region: {
|
||||||
// type: DataTypes.STRING,
|
// type: DataTypes.STRING,
|
||||||
// allowNull: false,
|
// allowNull: false,
|
||||||
// references: {
|
// references: {
|
||||||
// model: Region(sequelize, DataTypes),
|
// model: Region(sequelize, DataTypes),
|
||||||
// key: 'name'
|
// key: 'name'
|
||||||
// }
|
// }
|
||||||
// },
|
// },
|
||||||
organization_id: {
|
organization_id: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
allowNull: false,
|
allowNull: false,
|
||||||
references: {
|
references: {
|
||||||
model: Organization(sequelize, DataTypes),
|
model: Organization(sequelize, DataTypes),
|
||||||
key: 'id'
|
key: 'id'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
number_people_impacted: {
|
||||||
|
type: DataTypes.INTEGER,
|
||||||
|
defaultValue: 0
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
number_people_impacted: {
|
{
|
||||||
type: DataTypes.INTEGER,
|
freezeTableName: true,
|
||||||
defaultValue: 0
|
|
||||||
|
// define the table's name
|
||||||
|
tableName: 'projects'
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
|
|
||||||
return Project;
|
return Project;
|
||||||
};
|
};
|
||||||
|
|||||||
+16
-7
@@ -1,11 +1,20 @@
|
|||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const Region = sequelize.define('Region', {
|
const Region = sequelize.define(
|
||||||
id: {
|
'Region',
|
||||||
type: DataTypes.INTEGER,
|
{
|
||||||
primaryKey: true,
|
id: {
|
||||||
autoIncrement: true
|
type: DataTypes.INTEGER,
|
||||||
|
primaryKey: true,
|
||||||
|
autoIncrement: true
|
||||||
|
},
|
||||||
|
name: { type: DataTypes.STRING, allowNull: false, unique: true }
|
||||||
},
|
},
|
||||||
name: { type: DataTypes.STRING, allowNull: false, unique: true }
|
{
|
||||||
});
|
freezeTableName: true,
|
||||||
|
|
||||||
|
// define the table's name
|
||||||
|
tableName: 'regions'
|
||||||
|
}
|
||||||
|
);
|
||||||
return Region;
|
return Region;
|
||||||
};
|
};
|
||||||
|
|||||||
+24
-15
@@ -1,21 +1,30 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const User = sequelize.define('User', {
|
const User = sequelize.define(
|
||||||
id: {
|
'User',
|
||||||
type: DataTypes.INTEGER,
|
{
|
||||||
primaryKey: true,
|
id: {
|
||||||
autoIncrement: true,
|
type: DataTypes.INTEGER,
|
||||||
allowNull: false
|
primaryKey: true,
|
||||||
},
|
autoIncrement: true,
|
||||||
first_name: DataTypes.STRING,
|
allowNull: false
|
||||||
last_name: DataTypes.STRING,
|
|
||||||
email: {
|
|
||||||
type: DataTypes.STRING,
|
|
||||||
validate: {
|
|
||||||
isEmail: true
|
|
||||||
},
|
},
|
||||||
allowNull: false
|
first_name: DataTypes.STRING,
|
||||||
|
last_name: DataTypes.STRING,
|
||||||
|
email: {
|
||||||
|
type: DataTypes.STRING,
|
||||||
|
validate: {
|
||||||
|
isEmail: true
|
||||||
|
},
|
||||||
|
allowNull: false
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
freezeTableName: true,
|
||||||
|
|
||||||
|
// define the table's name
|
||||||
|
tableName: 'users'
|
||||||
}
|
}
|
||||||
});
|
);
|
||||||
return User;
|
return User;
|
||||||
};
|
};
|
||||||
|
|||||||
Reference in New Issue
Block a user