working proper seeding
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
const db = require('../../config/db.config.js'),
|
||||
bcrypt = require('bcrypt-nodejs'),
|
||||
errorMaker = require('../../helpers/error.maker');
|
||||
errorMaker = require('../../helpers/error.maker'),
|
||||
uuidv4 = require('uuid/v4');
|
||||
|
||||
const Donor = db.Donor;
|
||||
|
||||
@@ -23,6 +24,7 @@ exports.create = (req, res, next) => {
|
||||
return next(error);
|
||||
} else {
|
||||
Donor.create({
|
||||
id: uuidv4(),
|
||||
first_name: req.body.first_name,
|
||||
middle_name: req.body.middle_name,
|
||||
last_name: req.body.last_name,
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
const db = require('../../config/db.config.js'),
|
||||
bcrypt = require('bcrypt-nodejs'),
|
||||
errorMaker = require('../../helpers/error.maker');
|
||||
errorMaker = require('../../helpers/error.maker'),
|
||||
uuidv4 = require('uuid/v4');
|
||||
|
||||
const { Grant, Cause, Region, Organization } = db;
|
||||
|
||||
@@ -74,6 +75,7 @@ exports.create = async (req, res, next) => {
|
||||
|
||||
// Store hash in DB
|
||||
const org = await Organization.create({
|
||||
id: uuidv4(),
|
||||
name,
|
||||
short_description,
|
||||
|
||||
@@ -107,6 +109,7 @@ exports.create = async (req, res, next) => {
|
||||
org
|
||||
});
|
||||
} catch (error) {
|
||||
console.log(error);
|
||||
await transaction.rollback();
|
||||
next(error);
|
||||
}
|
||||
|
||||
@@ -1,11 +1,9 @@
|
||||
const uuidv4 = require('uuid/v4');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Donor = sequelize.define('donors', {
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: uuidv4()
|
||||
allowNull: false,
|
||||
primaryKey: true
|
||||
},
|
||||
stripe_id: {
|
||||
type: DataTypes.UUID,
|
||||
|
||||
@@ -1,13 +1,12 @@
|
||||
const uuidv4 = require('uuid/v4'),
|
||||
Cause = require('./cause.model'),
|
||||
const Cause = require('./cause.model'),
|
||||
Region = require('./region.model');
|
||||
|
||||
module.exports = (sequelize, DataTypes) => {
|
||||
const Organization = sequelize.define('organizations', {
|
||||
id: {
|
||||
type: DataTypes.UUID,
|
||||
primaryKey: true,
|
||||
defaultValue: uuidv4()
|
||||
allowNull: false,
|
||||
primaryKey: true
|
||||
},
|
||||
name: { type: DataTypes.STRING, allowNull: false },
|
||||
short_description: { type: DataTypes.STRING, allowNull: false },
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'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
|
||||
module.exports = {
|
||||
@@ -8,6 +9,7 @@ module.exports = {
|
||||
|
||||
return queryInterface.bulkInsert('donors', [
|
||||
{
|
||||
id: uuidv4(),
|
||||
first_name: 'Arjun',
|
||||
last_name: 'Patel',
|
||||
email: 'patelarjun50@gmail.com',
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
'use strict';
|
||||
const bcrypt = require('bcrypt-nodejs');
|
||||
const bcrypt = require('bcrypt-nodejs'),
|
||||
uuidv4 = require('uuid/v4');
|
||||
|
||||
module.exports = {
|
||||
up: async (queryInterface, Sequelize) => {
|
||||
@@ -7,6 +8,7 @@ module.exports = {
|
||||
|
||||
return queryInterface.bulkInsert('organizations', [
|
||||
{
|
||||
id: uuidv4(),
|
||||
name: 'Gopala Goshala',
|
||||
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',
|
||||
@@ -33,70 +35,71 @@ module.exports = {
|
||||
primary_contact_first_name: 'Kamlesh',
|
||||
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: 'ajay@gmail.com',
|
||||
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: 'cancersupport@gmail.com',
|
||||
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(),
|
||||
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: 'ajay@gmail.com',
|
||||
// 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: 'cancersupport@gmail.com',
|
||||
// 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