-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathseed.js
78 lines (68 loc) · 2.13 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
/* This script seeds the db with testData data for the Image Gallery API */
/* I am using mongodb locally with config from README.md */
let db = require('./db/index.js');
let testData = require('./server/testJson.js');
/* seed a number of cats */
let NUM_CATS = 100;
for(let i = 0; i < NUM_CATS; i++) {
db.createProductRecord(testData.giveMeCats('testData' + i) ,(err, result) => {
if(err) {
console.log('ERROR there are likely duplicate entries');
} else {
console.log('creating product testData' + i);
}
})
}
/* seed some animals */
db.createProductRecord(testData.giveMeCats('cats') ,(err, result) => {
if(err) {
console.log('ERROR there are likely duplicate entries');
} else {
console.log('creating product cats');
}
})
db.createProductRecord(testData.giveMeDogs('dogs') ,(err, result) => {
if(err) {
console.log('ERROR there are likely duplicate entries');
} else {
console.log('creating product dogs');
}
})
/* seed actual products */
db.createProductRecord(testData.giveMeFlashlight('flashlight') ,(err, result) => {
if(err) {
console.log('ERROR there are likely duplicate entries');
} else {
console.log('creating product flashlight');
}
})
db.createProductRecord(testData.giveMeHeadphones('headphones') ,(err, result) => {
if(err) {
console.log('ERROR there are likely duplicate entries');
} else {
console.log('creating product headphones');
}
})
db.createProductRecord(testData.giveMeSeki('seki-kit') ,(err, result) => {
if(err) {
console.log('ERROR there are likely duplicate entries');
} else {
console.log('creating product seki-kit');
}
})
db.createProductRecord(testData.giveMeKeyboard('keyboard') ,(err, result) => {
if(err) {
console.log('ERROR there are likely duplicate entries');
} else {
console.log('creating product keyboard');
}
})
db.createProductRecord(testData.giveMeWatches('watch') ,(err, result) => {
if(err) {
console.log('ERROR there are likely duplicate entries');
} else {
console.log('creating product watch');
}
})
/* A hack, change to Promise.all please */
setTimeout(process.exit, 1000)