File tree Expand file tree Collapse file tree 2 files changed +104
-0
lines changed
Expand file tree Collapse file tree 2 files changed +104
-0
lines changed Original file line number Diff line number Diff line change 11const uuid = require ( 'uuid4' ) ;
2+ const randomWords = require ( 'random-words' ) ;
23const entities = require ( '../data/entity.json' ) ;
34
45module . exports = {
@@ -15,6 +16,65 @@ module.exports = {
1516 element . address = JSON . stringify ( element . address ) ;
1617 }
1718
19+ let i = 0 ;
20+ const entityNames = [
21+ "Springfield Bowlorama" ,
22+ "Springfield Nuclear Power Plant" ,
23+ "Androids Dungeon" ,
24+ "Kwik-E-Mart" ,
25+ "Krusty Burger" ,
26+ "Duff Brewery" ,
27+ "Aztech Theater" ,
28+ "The Copy Jalopy"
29+ ] ;
30+
31+ for ( let name of entityNames ) {
32+ entities . push ( {
33+ id : uuid ( ) ,
34+ createdAt : new Date ( ) ,
35+ updatedAt : new Date ( ) ,
36+ name : name ,
37+ address : JSON . stringify ( {
38+ street : [
39+ `123 ${ randomWords ( ) } St.`
40+ ] ,
41+ city : "Baltimore" ,
42+ state : "MD" ,
43+ zip : "12345" ,
44+ latlng : [
45+ 39.296399 ,
46+ - 76.607842
47+ ]
48+ } ) ,
49+ description : randomWords ( 5 )
50+ } ) ;
51+ }
52+
53+ // do {
54+ // let name = randomWords();
55+ // entities.push({
56+ // id: uuid(),
57+ // createdAt: new Date(),
58+ // updatedAt: new Date(),
59+ // name: name.charAt(0).toUpperCase() + name.slice(1),
60+ // address: JSON.stringify({
61+ // street: [
62+ // "123 Anyplace St."
63+ // ],
64+ // city: "Baltimore",
65+ // state: "MD",
66+ // zip: "12345",
67+ // latlng: [
68+ // 39.296399,
69+ // -76.607842
70+ // ]
71+ // }),
72+ // description: randomWords(5)
73+ // });
74+ // i++;
75+ // } while (i < 26);
76+
77+
1878 return queryInterface . bulkInsert ( 'Entities' , entities ) ;
1979 } ,
2080 down : queryInterface => {
Original file line number Diff line number Diff line change 11const uuid = require ( 'uuid4' ) ;
2+ const randomWords = require ( 'random-words' ) ;
23const contacts = require ( '../data/contact.json' ) ;
34
45module . exports = {
@@ -20,6 +21,49 @@ module.exports = {
2021 }
2122 }
2223
24+ let i = 0 ;
25+ do {
26+ const entityNames = [
27+ "Springfield Bowlorama" ,
28+ "Springfield Nuclear Power Plant" ,
29+ "Androids Dungeon" ,
30+ "Kwik-E-Mart" ,
31+ "Krusty Burger" ,
32+ "Duff Brewery" ,
33+ "Aztech Theater"
34+ ] ;
35+ let name = randomWords ( ) ;
36+
37+ let entityId = await queryInterface . sequelize . query (
38+ `SELECT id FROM ${ process . env . DATABASE_SCHEMA } ."Entities" WHERE name = '${ entityNames [ Math . floor ( Math . random ( ) * entityNames . length ) ] } '`
39+ ) ;
40+
41+ let contact = {
42+ id : uuid ( ) ,
43+ createdAt : new Date ( ) ,
44+ updatedAt : new Date ( ) ,
45+ name : name . charAt ( 0 ) . toUpperCase ( ) + name . slice ( 1 ) ,
46+ email : JSON . stringify ( [
47+ {
48+ address : `${ randomWords ( ) } @test.test` ,
49+ isPrimary : true
50+ }
51+ ] ) ,
52+ phone : JSON . stringify ( [
53+ {
54+ number : ( Math . floor ( Math . random ( ) * Math . floor ( 100000000000 ) ) ) . toString ( ) ,
55+ isPrimary : true
56+ }
57+ ] )
58+ } ;
59+
60+ if ( entityId [ 0 ] [ 0 ] !== undefined ) contact . EntityId = entityId [ 0 ] [ 0 ] . id ;
61+
62+ contacts . push ( contact ) ;
63+
64+ i ++ ;
65+ } while ( i < 18 ) ;
66+
2367 return queryInterface . bulkInsert ( 'Contacts' , contacts ) ;
2468 } ,
2569 down : queryInterface => {
You can’t perform that action at this time.
0 commit comments