-
Notifications
You must be signed in to change notification settings - Fork 7
/
loadsampledata.js
84 lines (69 loc) · 2.33 KB
/
loadsampledata.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
// Warning - Don't Touch This File It Might Result in Some Error
require('colors')
const Jokes = require('./models/jokes')
const Animals = require('./models/animals')
const Credits = require('./models/FakeCredit')
const flirts = require('./models/flirt')
const insults = require('./models/insults')
const mongoose = require('mongoose')
require('dotenv').config()
const jokesData = require('./sample/jokes').jokes
const animalsData = require('./sample/animals').animals
const creditsData = require('./sample/credits').cards
const flirtData = require('./sample/flirts')
const insltsData = require('./sample/insults')
async function loadData () {
try {
console.clear()
await mongoose.connect(process.env.MONGOSRV, {
useNewUrlParser: true,
useUnifiedTopology: true,
useFindAndModify: false
})
console.clear()
console.log('[+] Connected to Database\n'.green)
console.log('[+] Inserting Data Started!\n'.green)
for (let i = 0; i < jokesData.length; i++) {
await Jokes.create({
joke: jokesData[i].joke,
category: jokesData[i].category
})
}
console.log('[+] Successfully Inserted Jokes!\n'.green)
for (let i = 0; i < animalsData.length; i++) {
await Animals.create({
image: animalsData[i].image,
fact: animalsData[i].fact,
animal: animalsData[i].animal
})
}
console.log('[+] Successfully Inserted Animals!\n'.green)
for (let i = 0; i < creditsData.length; i++) {
await Credits.create({
type: creditsData[i].type,
number: creditsData[i].number,
expiration: creditsData[i].expiration,
owner: creditsData[i].owner
})
}
console.log('[+] Successfully Inserted Fake Credit Cards!\n'.green)
for (let i = 0; i < flirtData.length; i++) {
await flirts.create({
flirt: creditsData[i].flirt
})
}
console.log('[+] Successfully Inserted Flirts!\n'.green)
for (let i = 0; i < insltsData.length; i++) {
await insults.create({
insult: creditsData[i].insult
})
}
console.log('[+] Successfully Inserted Insults!\n'.green)
console.log('[+] Operation Successfully!\n'.green)
process.exit()
} catch (e) {
console.log(e)
process.exit()
}
};
loadData()