-
Notifications
You must be signed in to change notification settings - Fork 1
/
seed.js
890 lines (874 loc) · 27.1 KB
/
seed.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
/*
This seed file is only a placeholder. It should be expanded and altered
to fit the development of your application.
It uses the same file the server uses to establish
the database connection:
--- server/db/index.js
The name of the database used is set in your environment files:
--- server/env/*
This seed file has a safety check to see if you already have users
in the database. If you are developing multiple applications with the
fsg scaffolding, keep in mind that fsg always uses the same database
name in the environment files.
*/
var mongoose = require('mongoose');
var Promise = require('bluebird');
var chalk = require('chalk');
var connectToDb = require('./server/db');
var User = Promise.promisifyAll(mongoose.model('User'));
var Event = Promise.promisifyAll(mongoose.model('Event'));
var Chance = require('chance');
var chance = new Chance();
var moment = require('moment');
moment().format();
var getRandomLocation = function() { //change this later to take a sport and return a location that makes sense for the sport input.
var locations = [
{latitude: 40.771606, longitude: -73.974819},
{latitude: 40.746617, longitude: -74.010184},
{latitude: 40.727127, longitude: -74.011334},
{latitude: 40.781389, longitude: -73.966553},
{latitude: 40.716920, longitude: -74.016867},
{latitude: 40.731041, longitude: -74.001244},
]
return locations[Math.floor(Math.random()*locations.length)];
}
var getRandomLevel = function() {
var levels = ['Beginner (1-2)', 'Novice (3-4)', 'Intermediate(5-6)', 'Advanced(7-8)', 'Pro(9-10)'];
return levels[Math.floor(Math.random()*levels.length)];
}
var getRandomSport = function() {
var sports = ["Basketball", "Climbing", "Soccer", "Baseball", "Football", "Lifting", "Skiing", "Mountain Biking", "Surfing", "Cycling", 'Tennis']
return sports[Math.floor(Math.random()*sports.length)];
}
var getRandomTags = function(n) {
var taglist = [];
var tags = [{text: 'Fun'}, {text:'Awesome'}, {text:'Cool'}, {text:'Advanced'}, {text:'Easy'}, {text:'Hardcore'}, {text:'Music'}, {text:'Weekend'}, {text:'Day Trip'}, {text:'Night Time'}, {text:'Day Time'}, {text:'After Work'}, {text:'Kids'}, {text:'Adults'}, {text:'Intermediate'}];
while(taglist.length < n) {
if (taglist.length === tags.length) {
break;
}
var randtag = tags[Math.floor(Math.random()*tags.length)]
taglist.push(randtag)
}
return taglist;
}
var genRandomEvents = function(num) {
return User.find({}).then(function(allUsers){
console.log(allUsers);
var events = [];
var address1 = [" 11-11 44th Dr",
"23-10 41st Ave",
"130 Clinton St",
"1506 Lexington Ave",
"482 W 43rd St",
"60 Chelsea Piers",
"575 Degraw St",
"Central Park Driveway",
"W. 76 St. & Riverside Drive",
"104 St. & 2 Ave.",
"E. 84 St. & York Ave.",
"E. 99 St. & 3 Ave.",
"E. 128 St. & 2 Ave.",
"E. 10 St. & FDR Drive",
"W. 140 St. & Hamilton Pl.",
"150 St. & Bradhurst Ave.",
"W. 136 St. & Amsterdam Ave.",
"W. 113 St. & Morningside",
"W. 116 St. & Morningside",
"W. 123 St. & Morningside",
"E. 118 St. & 2 Ave.",
"E. 109 St. & 3 Ave.",
"W. 141 St. & St. Nicholas Ave.",
"W. 133 St. & St. Nicholas Ave.",
"W. 129 St. & St. Nicholas Ave.",
"W. 4th St. & 6th Avenue",
"Great Lawn",
"299 South St",
"Delancey St",
"E Houston St",
"E 10 St. & Ave. B",
"E. 120 to 124 Sts. and Madison Ave.",
"W. 28 St. between 9 and 10 Aves.",
"West 25 Street and 10 Avenue",
"81-85 Streets Between East and West Drives",
"64 St. Between West and Center Drives",
"97-102 Streets Between East and West Drives",
"W. 27 St. & 9 Ave.",
"143 St. & Lenox Ave.",
"Market & Monroe Streets",
"Jackson St. at Waters St.",
"11 Ave. & 53 St.",
"Grand St. & FDR Drive",
"10th Street",
"W 165 St. & Hudson River",
"E. 128 St. & 3 Ave.",
"W 170 St. & Amsterdam Ave.",
"W 207 St. & Seaman Ave.",
"150 St. & Bradhurst Ave.",
"Hudson Leroy and Clarkson Streets",
"W. 110 St. & Morningside Ave.",
"155 St. & 8 Ave.",
"E. 59 St. & Sutton Pl.",
"Randall's Island",
"Randall's Island",
"Randall's Island",
"Randall's Island",
"W 104-107 Streets & Riverside Park",
"W 72 St. & Riverside Park",
"1 to 2 avenues, East 35 to East 36 streets",
"E. 111-112 Streets, East River and 1 Ave.",
"Mid-Park from 97th to 102nd streets",
"11th Avenue & West 52nd Street",
"Montgomery Street to East 12th Street & FDR Drive",
"20 Randalls Island",
"Dyckman Street & Hudson River",
"Grand Street & Broome Street",
"Between Rivington & Stanton streets",
"Randall's Island",
"Randall's Island",
"Randall's Island",
"Randall's Island",
"Randall's Island",
"Randall's Island",
"1st Avenue & East 111th Street",
"East 25th Street and Asser Levy Place",
"11th Avenue & West 52nd Street",
"Montogomery Street to East 12th Street & F.D.R Drive",
"East River & Harlem River",
"1 to 2 avenues, East 35 to East 36 streets",
"Randall's Island Park",
"At Houston St. (walk east over FDR Drive)",
"93d St. near West Drive",
"Hudson River at 170th St.",
"151st St. east of 7th Ave.",
"207th St. and Seaman Ave.",
"Riverside Drive and W. 96th St.",
"Chambers St. & West St.",
"1 Randall's Island",
"1030 86th St & 7th Ave",
"2880 Flatbush Ave",
"100 Flushing Meadows Pedestrian Bridge",
"59 Chelsea Piers",
"225 West St",
"61 Chelsea Piers",
"47-32 32nd Pl",
"830 5th Ave",
"3159 Flatbush Ave",
"61 Wythe Ave",
"200 N 14th St",
"222 W 44th St",
"NY-9A",
"550 9th Ave",
"624-660 W. 42nd Street",
"80 Catherine Street",
"Asser Levy Place",
"430 West 25th Street",
"232 West 60th Street",
"128 Pitt Street",
"35 West 134th Street",
"2301 Amsterdam Avenue",
"351 Fort Washington Avenue",
"85 Bradhurst Avenue",
"410 West 123rd Street",
"Central Park",
"18 Mount Morris Park West",
"348 East 54th Street",
"2180 1st Avenue",
"3 Clarkson Street"]
var address2 = ["The Cliffs",
"Brooklyn Boulders Queenbridge",
"Everyday Athlete",
"Steep Rock Bouldering",
"Manhattan Plaza Health Club",
"The Sports Center at Chelsea Piers",
"Brooklyn Boulders",
"Umpire Rock",
"76 St. Playground",
"Blake Hobbs Park",
"Carl Schurz Park",
"Cherry Tree Park",
"Crack is Wack",
"East River Park",
"Hamilton Place",
"Jackie Robinson Park",
"Jacob Schiff Playground",
"Morningside Park",
"Morningside Park",
"Morningside Park",
"Morningside Playground",
"Poor Richard Playground",
"St. Nicholas Park",
"St. Nicholas Park",
"St. Nicholas Terrace",
"West 4th St. Courts",
"Central Park",
"Basketball City",
"Luther Gulick Playground",
"ABC Playground",
"Tompkins Sq. Park",
"Marcus Garvey Park",
"Chelsea Park",
"Chelsea Recreation Center",
"Central Park - Great Lawn",
"Central Park - Heckscher",
"Central Park - North Meadow",
"Chelsea Park",
"Col. Charles Young Playground",
"Coleman Square Playground",
"Corlears Hook Park Ballfield",
"De Witt Clinton Park",
"East River Park",
"East River Park",
"Ft. Washington Park",
"Harlem River Drive Park",
"Highbridge Park",
"Inwood Hill Park",
"Jackie Robinson Park",
"James J. Walker",
"Morningside Park",
"PS 156 - Holcombe Rucker Plgd.",
"Queensboro Oval",
"Randall's Island Central Fields",
"Randall’s Island — Bronx Shore",
"Randall’s Island — Hell Gate Fields",
"Randall’s Island — Sunken Meadow",
"Riverside Park",
"Riverside Park",
"St. Vartan Playground",
"Thomas Jefferson Park",
"Central Park - North Meadow (Seasonal)",
"De Witt Clinton Park",
"East River Park",
"Icahn Stadium Complex",
"Inwood Hill Park-Dyckman Fields",
"Lions Gate Field",
"Nike Field",
"Randall’s Island — Central Fields",
"Randall’s Island — East River Fields",
"Randall’s Island — Hell Gate Fields",
"Randall’s Island — Sunken Garden Fields",
"Randall’s Island — Sunken Meadow",
"Randall’s Island — Wards Meadow Fields",
"Thomas Jefferson Park",
"Asser Levy Playground",
"De Witt Clinton Park",
"East River Park",
"Randall's Island",
"St. Vartan Playground",
"Sportime at Randall's Island",
"Brian Watkins Tennis Center",
"Central Park",
"Fort Washington Park",
"Frederick Johnson Playground",
"Inwood Hill Park",
"Riverside Park",
"Washington Market Park",
"Randall's Island Golf Center",
"Dyker Beach Golf Course",
"Marine Park Golf Course",
"Flushing Meadows Corona Park Golf Center",
"The Golf Club at Chelsea Piers",
"Pier 25 Mini Golf",
"Sky Rink at Chelsea Piers",
"City Ice Pavilion",
"Lasker Rink",
"Aviator Sports and Events Center",
"Brooklyn Bowl",
"The Gutter",
"Bowlmor Times Square",
"Bowlmor Chelsea Piers",
"Frames Bowling Lounge",
"Lucky Strike Manhattan",
"Alfred E. Smith Recreation Center",
"Asser Levy Recreation Center",
"Chelsea Recreation Center",
"Gertrude Ederle Recreation Center",
"Hamilton Fish Recreation Center",
"Hansborough Recreation Center",
"Highbridge Recreation Center",
"J. Hood Wright Recreation Center",
"Jackie Robinson Recreation Center",
"Morningside Field House",
"North Meadow Recreation Center",
"Pelham Fritz Recreation Center",
"Recreation Center 54",
"Thomas Jefferson Recreation Center",
"Tony Dapolito Recreation Center"
]
var cities = ["Long Island City",
"New York",
"Brooklyn",
"New York",
"New York",
"New York",
"Brooklyn",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"Brooklyn",
"Brooklyn",
"Flushing",
"New York",
"New York",
"New York",
"Long Island City",
"New York",
"Brooklyn",
"Brooklyn",
"Brooklyn",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York",
"New York"]
var latitudes = ["40.7509995",
"40.7528075",
"40.6925522",
"40.7867848",
"40.7598933",
"40.746678",
"40.679661",
"40.7691162",
"40.7831884",
"40.7893042",
"40.7746085",
"40.7871375",
"40.8046117",
"40.7241783",
"40.8226499",
"40.82642",
"40.8195698",
"40.8039774",
"40.8061032",
"40.8100649",
"40.7982971",
"40.7935015",
"40.8212556",
"40.8157039",
"40.8131496",
"40.7317057",
"40.7823792",
"40.7096355",
"40.7158291",
"40.7217871",
"40.7265027",
"40.8044924",
"40.7501121",
"40.7483029",
"40.7703852",
"40.7684844",
"40.7917758",
"40.7501121",
"40.8195904",
"40.7112051",
"40.7116965",
"40.768136",
"40.7153271",
"40.72321775",
"40.8494774",
"40.8064725",
"40.8433959",
"40.8715417",
"40.824293",
"40.7298392",
"40.8050933",
"40.8297309",
"40.7586502",
"40.795813",
"40.7992515",
"40.7773974",
"40.795813",
"40.8012339",
"40.7813035",
"40.7449676",
"40.7933657",
"40.7917758",
"40.768136",
"40.7153271",
"40.7927643",
"40.8715417",
"40.7184361",
"40.7223972",
"40.795813",
"40.7838316",
"40.7773974",
"40.7863869",
"40.795813",
"40.782513",
"40.7933657",
"40.7361338",
"40.768136",
"40.7153271",
"40.7838316",
"40.7449676",
"40.7927407",
"40.7153271",
"40.78943668",
"40.8494774",
"40.8248117",
"40.868976",
"40.7958304",
"40.7169743",
"40.796406",
"40.6122928",
"40.5999394",
"40.7513277",
"40.745533",
"40.7202307",
"40.7476265",
"40.741632",
"40.7961278",
"40.5903237",
"40.7219339",
"40.7225793",
"40.757655",
"40.746571",
"40.7571868",
"40.761484",
"40.7101888",
"40.7361338",
"40.7483029",
"40.7714308",
"40.7200294",
"40.8127962",
"40.8427677",
"40.846546",
"40.824293",
"40.8050933",
"40.7911351",
"40.8050093",
"40.7565447",
"40.7936402",
"40.729582"]
var longitudes = [
"-73.9410019",
"-73.9404022",
"-73.9934896",
"-73.9506709",
"-73.9945513",
"-74.010241",
"-73.98424",
"-73.9778139",
"-73.9844687",
"-73.9433973",
"-73.9480883",
"-73.947915",
"-73.9321757",
"-73.973506",
"-73.9513001",
"-73.9405891",
"-73.95173",
"-73.9603273",
"-73.9593701",
"-73.9549701",
"-73.9367982",
"-73.9432657",
"-73.9460791",
"-73.9486662",
"-73.9503285",
"-74.0009542",
"-73.9658585",
"-73.9862753",
"-73.9818676",
"-73.9860332",
"-73.9816975",
"-73.9440646",
"-74.0011837",
"-74.0020469",
"-73.976581",
"-73.9772017",
"-73.9587593",
"-74.0011837",
"-73.9361885",
"-73.9936545",
"-73.9796972",
"-73.9943891",
"-73.9754516",
"73.97291064",
"-73.9466407",
"-73.9341451",
"-73.9332427",
"-73.9256948",
"-73.9421716",
"-74.0063254",
"-73.9591266",
"-73.9354549",
"-73.9583874",
"-73.922517",
"-73.9230296",
"-73.9346962",
"-73.922517",
"-73.9723096",
"-73.9865841",
"-73.9736364",
"-73.9352473",
"-73.9587593",
"-73.9943891",
"-73.9754516",
"-73.9246912",
"-73.9256948",
"-73.9932447",
"-73.9916358",
"-73.922517",
"-73.933568",
"-73.9346962",
"-73.9306548",
"-73.922517",
"-73.9289096",
"-73.9352473",
"-73.9756491",
"-73.9943891",
"-73.9754516",
"-73.933568",
"-73.9736364",
"-73.9193284",
"-73.9754516",
"-73.96199942",
"-73.9466407",
"-73.9355668",
"-73.9216708",
"-73.9741477",
"-74.011467",
"-73.923066",
"-74.0192358",
"-73.9143984",
"-73.8397009",
"-74.010053",
"-74.0141182",
"-74.0096552",
"-73.9333151",
"-73.9549052",
"-73.899774",
"-73.9573519",
"-73.9554117",
"-73.987187",
"-74.0094885",
"-73.9932062",
"-74.0009669",
"-73.9976097",
"-73.9756491",
"-74.0020469",
"-73.9886621",
"-73.9815585",
"-73.9392323",
"-73.9341341",
"-73.9408265",
"-73.9421716",
"-73.9591266",
"-73.9596776",
"-73.9448633",
"-73.965084",
"-73.9367813",
"-74.005479"
]
var locationSports = ["Climbing",
"Climbing",
"Climbing",
"Climbing",
"Climbing",
"Climbing",
"Climbing",
"Climbing",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Basketball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Baseball",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Soccer",
"Football",
"Football",
"Football",
"Football",
"Football",
"Tennis",
"Tennis",
"Tennis",
"Tennis",
"Tennis",
"Tennis",
"Tennis",
"Tennis",
"Golf",
"Golf",
"Golf",
"Golf",
"Golf",
"Golf",
"Hockey",
"Hockey",
"Hockey",
"Hockey",
"Bowling",
"Bowling",
"Bowling",
"Bowling",
"Bowling",
"Bowling",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting",
"Lifting"]
var locations = [];
var adjectives = ['Awesome', 'Fun', 'Cool', 'Fantastic', 'Powerful', 'Funny', 'Light', 'Easy', 'Tough', 'Great', 'The Best', 'All Day', 'Intense', 'Fierce'];
var times = ['11:00', '11:30', '12:00', '12:30', '1:00', '1:30', '2:00', '2:30', '3:00', '3:30', '4:00', '4:30', '5:00', '5:30', '6:00', '6:30', '7:00', '7:30', '8:00', '8:30', '9:00', '9:30', '10:00'];
for (i=0;i<address1.length;i++){
var locationObj = {
address1: address1[i],
address2: address2[i],
city: cities[i],
latitude: latitudes[i],
longitude: longitudes[i],
sport: locationSports[i]
}
locations.push(locationObj);
}
for(i=0;i<num;i++) {
var chosenLocation = chance.pick(locations);
var chosenAdj = chance.pick(adjectives);
var newEvent = {
host: chance.pick(allUsers)._id,
sport: chosenLocation.sport,
name: chosenAdj+' '+chosenLocation.sport+' Event',
dateTime: {
date: chance.date({string: true, year: 2015, month: 11, day: chance.integer({min: 11, max: 31})}),
time: chance.pick(times),
ampm: chance.ampm()
},
location: {
latitude: chosenLocation.latitude,
longitude: chosenLocation.longitude
},
level: getRandomLevel(),
tags: getRandomTags(),
description: chance.paragraph({sentences: 1})
}
events.push(newEvent);
}
return events;
});
}
var seedUsers = function(num) {
var users = [
{
userName: 'Jugal',
email: '[email protected]',
password: 'jugal'
},
{
userName: 'June',
email: '[email protected]',
password: 'june'
},
{
userName: 'Mingjie',
email: '[email protected]',
password: 'mingjie'
},
{
userName: 'Bryce',
email: '[email protected]',
password: 'bryce'
}
];
for(i=0;i<num;i++) {
var nextUser = {
userName: chance.first(),
email: chance.last()+'@fsa.com',
password: 'password'
}
users.push(nextUser);
}
return User.createAsync(users);
};
var seedEvents = function(num) {
return genRandomEvents(num).then(function(events){
return Event.createAsync(events);
});
};
connectToDb.then(function () {
User.findAsync({}).then(function (users) {
if (users.length === 0) {
return seedUsers(21);
} else {
console.log(chalk.magenta('Seems to already be user data, exiting!'));
process.kill(0);
}
})
.then(function(){
console.log(chalk.yellow('Seeding Events...'));
return seedEvents(75);
})
.then(function () {
console.log(chalk.green('Seed successful!'));
process.kill(0);
})
.catch(function (err) {
console.error(err);
process.kill(1);
});
});