working proper seeding
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
const db = require('../../config/db.config.js'),
|
const db = require('../../config/db.config.js'),
|
||||||
bcrypt = require('bcrypt-nodejs'),
|
bcrypt = require('bcrypt-nodejs'),
|
||||||
errorMaker = require('../../helpers/error.maker');
|
errorMaker = require('../../helpers/error.maker'),
|
||||||
|
uuidv4 = require('uuid/v4');
|
||||||
|
|
||||||
const Donor = db.Donor;
|
const Donor = db.Donor;
|
||||||
|
|
||||||
@@ -23,6 +24,7 @@ exports.create = (req, res, next) => {
|
|||||||
return next(error);
|
return next(error);
|
||||||
} else {
|
} else {
|
||||||
Donor.create({
|
Donor.create({
|
||||||
|
id: uuidv4(),
|
||||||
first_name: req.body.first_name,
|
first_name: req.body.first_name,
|
||||||
middle_name: req.body.middle_name,
|
middle_name: req.body.middle_name,
|
||||||
last_name: req.body.last_name,
|
last_name: req.body.last_name,
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
const db = require('../../config/db.config.js'),
|
const db = require('../../config/db.config.js'),
|
||||||
bcrypt = require('bcrypt-nodejs'),
|
bcrypt = require('bcrypt-nodejs'),
|
||||||
errorMaker = require('../../helpers/error.maker');
|
errorMaker = require('../../helpers/error.maker'),
|
||||||
|
uuidv4 = require('uuid/v4');
|
||||||
|
|
||||||
const { Grant, Cause, Region, Organization } = db;
|
const { Grant, Cause, Region, Organization } = db;
|
||||||
|
|
||||||
@@ -74,6 +75,7 @@ exports.create = async (req, res, next) => {
|
|||||||
|
|
||||||
// Store hash in DB
|
// Store hash in DB
|
||||||
const org = await Organization.create({
|
const org = await Organization.create({
|
||||||
|
id: uuidv4(),
|
||||||
name,
|
name,
|
||||||
short_description,
|
short_description,
|
||||||
|
|
||||||
@@ -107,6 +109,7 @@ exports.create = async (req, res, next) => {
|
|||||||
org
|
org
|
||||||
});
|
});
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
console.log(error);
|
||||||
await transaction.rollback();
|
await transaction.rollback();
|
||||||
next(error);
|
next(error);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,11 +1,9 @@
|
|||||||
const uuidv4 = require('uuid/v4');
|
|
||||||
|
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const Donor = sequelize.define('donors', {
|
const Donor = sequelize.define('donors', {
|
||||||
id: {
|
id: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
primaryKey: true,
|
allowNull: false,
|
||||||
defaultValue: uuidv4()
|
primaryKey: true
|
||||||
},
|
},
|
||||||
stripe_id: {
|
stripe_id: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
|
|||||||
@@ -1,13 +1,12 @@
|
|||||||
const uuidv4 = require('uuid/v4'),
|
const Cause = require('./cause.model'),
|
||||||
Cause = require('./cause.model'),
|
|
||||||
Region = require('./region.model');
|
Region = require('./region.model');
|
||||||
|
|
||||||
module.exports = (sequelize, DataTypes) => {
|
module.exports = (sequelize, DataTypes) => {
|
||||||
const Organization = sequelize.define('organizations', {
|
const Organization = sequelize.define('organizations', {
|
||||||
id: {
|
id: {
|
||||||
type: DataTypes.UUID,
|
type: DataTypes.UUID,
|
||||||
primaryKey: true,
|
allowNull: false,
|
||||||
defaultValue: uuidv4()
|
primaryKey: true
|
||||||
},
|
},
|
||||||
name: { type: DataTypes.STRING, allowNull: false },
|
name: { type: DataTypes.STRING, allowNull: false },
|
||||||
short_description: { type: DataTypes.STRING, allowNull: false },
|
short_description: { type: DataTypes.STRING, allowNull: false },
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const bcrypt = require('bcrypt-nodejs');
|
const bcrypt = require('bcrypt-nodejs'),
|
||||||
|
uuidv4 = require('uuid/v4');
|
||||||
|
|
||||||
// DOESNT WORK AS NEED TO HASH PASSWORD TO DB
|
// DOESNT WORK AS NEED TO HASH PASSWORD TO DB
|
||||||
module.exports = {
|
module.exports = {
|
||||||
@@ -8,6 +9,7 @@ module.exports = {
|
|||||||
|
|
||||||
return queryInterface.bulkInsert('donors', [
|
return queryInterface.bulkInsert('donors', [
|
||||||
{
|
{
|
||||||
|
id: uuidv4(),
|
||||||
first_name: 'Arjun',
|
first_name: 'Arjun',
|
||||||
last_name: 'Patel',
|
last_name: 'Patel',
|
||||||
email: '[email protected]',
|
email: '[email protected]',
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
const bcrypt = require('bcrypt-nodejs');
|
const bcrypt = require('bcrypt-nodejs'),
|
||||||
|
uuidv4 = require('uuid/v4');
|
||||||
|
|
||||||
module.exports = {
|
module.exports = {
|
||||||
up: async (queryInterface, Sequelize) => {
|
up: async (queryInterface, Sequelize) => {
|
||||||
@@ -7,6 +8,7 @@ module.exports = {
|
|||||||
|
|
||||||
return queryInterface.bulkInsert('organizations', [
|
return queryInterface.bulkInsert('organizations', [
|
||||||
{
|
{
|
||||||
|
id: uuidv4(),
|
||||||
name: 'Gopala Goshala',
|
name: 'Gopala Goshala',
|
||||||
short_description:
|
short_description:
|
||||||
'We are focused on bringing lawful animal treatment in North India. Check out our many projects such as city water fountains for animals',
|
'We are focused on bringing lawful animal treatment in North India. Check out our many projects such as city water fountains for animals',
|
||||||
@@ -33,70 +35,71 @@ module.exports = {
|
|||||||
primary_contact_first_name: 'Kamlesh',
|
primary_contact_first_name: 'Kamlesh',
|
||||||
primary_contact_last_name: 'Patel',
|
primary_contact_last_name: 'Patel',
|
||||||
|
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: uuidv4(),
|
||||||
|
name: 'The Pollination Project',
|
||||||
|
short_description:
|
||||||
|
'Every day of the year, we give a grant to changemakers across the globe.',
|
||||||
|
|
||||||
|
primary_contact_email: '[email protected]',
|
||||||
|
password: hashedPass,
|
||||||
|
|
||||||
|
address: '2031 Carry Drive',
|
||||||
|
city: 'San Francisco',
|
||||||
|
country: 'USA',
|
||||||
|
state: 'CA',
|
||||||
|
zip: '92604',
|
||||||
|
|
||||||
|
primary_cause: 'Human Services',
|
||||||
|
primary_region: 'Africa',
|
||||||
|
|
||||||
|
ein: '63-6088665',
|
||||||
|
estimate_asset_value: 200000,
|
||||||
|
estimate_yearly_operating_cost: 40000,
|
||||||
|
|
||||||
|
is_nonprofit: true,
|
||||||
|
|
||||||
|
primary_contact_phone: '6254581254',
|
||||||
|
primary_contact_first_name: 'Ajay',
|
||||||
|
primary_contact_last_name: 'Datta',
|
||||||
|
|
||||||
|
created_at: new Date(),
|
||||||
|
updated_at: new Date()
|
||||||
|
},
|
||||||
|
{
|
||||||
|
id: uuidv4(),
|
||||||
|
name: 'Cancer Global Perspective',
|
||||||
|
short_description:
|
||||||
|
'Your tax-deductible donation funds lifesaving research, treatment and care — and would mean so much to someone fighting cancer. Please donate today.',
|
||||||
|
|
||||||
|
primary_contact_email: '[email protected]',
|
||||||
|
password: hashedPass,
|
||||||
|
|
||||||
|
address: '82912 Larry Page Drive',
|
||||||
|
city: 'Holmes',
|
||||||
|
country: 'USA',
|
||||||
|
state: 'AZ',
|
||||||
|
zip: '92604',
|
||||||
|
|
||||||
|
primary_cause: 'Animal',
|
||||||
|
primary_region: 'South Asia',
|
||||||
|
|
||||||
|
ein: '63-6088665',
|
||||||
|
estimate_asset_value: 200000,
|
||||||
|
estimate_yearly_operating_cost: 40000,
|
||||||
|
|
||||||
|
is_nonprofit: true,
|
||||||
|
|
||||||
|
primary_contact_phone: '6254581254',
|
||||||
|
primary_contact_first_name: 'Leo',
|
||||||
|
primary_contact_last_name: 'Rosen',
|
||||||
|
|
||||||
created_at: new Date(),
|
created_at: new Date(),
|
||||||
updated_at: new Date()
|
updated_at: new Date()
|
||||||
}
|
}
|
||||||
// ,
|
|
||||||
// {
|
|
||||||
// name: 'The Pollination Project',
|
|
||||||
// short_description:
|
|
||||||
// 'Every day of the year, we give a grant to changemakers across the globe.',
|
|
||||||
|
|
||||||
// primary_contact_email: '[email protected]',
|
|
||||||
// password: hashedPass,
|
|
||||||
|
|
||||||
// address: '2031 Carry Drive',
|
|
||||||
// city: 'San Francisco',
|
|
||||||
// country: 'USA',
|
|
||||||
// state: 'CA',
|
|
||||||
// zip: '92604',
|
|
||||||
|
|
||||||
// primary_cause: 'Human Services',
|
|
||||||
// primary_region: 'Africa',
|
|
||||||
|
|
||||||
// ein: '63-6088665',
|
|
||||||
// estimate_asset_value: 200000,
|
|
||||||
// estimate_yearly_operating_cost: 40000,
|
|
||||||
|
|
||||||
// isNonprofit: true,
|
|
||||||
|
|
||||||
// primary_contact_phone: '6254581254',
|
|
||||||
// primary_contact_first_name: 'Ajay',
|
|
||||||
// primary_contact_last_name: 'Datta',
|
|
||||||
|
|
||||||
// created_at: new Date(),
|
|
||||||
// updated_at: new Date()
|
|
||||||
// },
|
|
||||||
// {
|
|
||||||
// name: 'Cancer Global Perspective',
|
|
||||||
// short_description:
|
|
||||||
// 'Your tax-deductible donation funds lifesaving research, treatment and care — and would mean so much to someone fighting cancer. Please donate today.',
|
|
||||||
|
|
||||||
// primary_contact_email: '[email protected]',
|
|
||||||
// password: hashedPass,
|
|
||||||
|
|
||||||
// address: '82912 Larry Page Drive',
|
|
||||||
// city: 'Holmes',
|
|
||||||
// country: 'USA',
|
|
||||||
// state: 'AZ',
|
|
||||||
// zip: '92604',
|
|
||||||
|
|
||||||
// primary_cause: 'Animal',
|
|
||||||
// primary_region: 'South Asia',
|
|
||||||
|
|
||||||
// ein: '63-6088665',
|
|
||||||
// estimate_asset_value: 200000,
|
|
||||||
// estimate_yearly_operating_cost: 40000,
|
|
||||||
|
|
||||||
// isNonprofit: true,
|
|
||||||
|
|
||||||
// primary_contact_phone: '6254581254',
|
|
||||||
// primary_contact_first_name: 'Leo',
|
|
||||||
// primary_contact_last_name: 'Rosen',
|
|
||||||
|
|
||||||
// created_at: new Date(),
|
|
||||||
// updated_at: new Date()
|
|
||||||
// }
|
|
||||||
]);
|
]);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user