-
Notifications
You must be signed in to change notification settings - Fork 0
/
seed.js
180 lines (177 loc) · 4.69 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
// const User = require('/server/db/user');
// const Hash = require('/server/')
var Promise = require('bluebird');
var db = require('./server/db/_db.js');
var User = require('./server/db/user');
var Article = require('./server/db/article');
var Hash = require('./server/db/hash');
var data = {
user: [
{
id: 1,
name: "justin",
email: "[email protected]",
numArticleTags: 3,
tags: [1, 0, 2, 0],
recommendations: [ ]
}, {
id: 2,
name: "ethan",
email: "[email protected]",
numArticleTags: 2,
tags: [0, 0, 0, 2],
recommendations: [ ]
}
],
article: [
{
title: "beer malting",
content: "did you know, the mayans used to soak the corn, chew it, then spit it out in the malting process, in order to get bacteria",
tags: [0, 1, 0, 0]
}, {
title: "wine-tomato pairing",
content: "needs an acidic flavor",
tags: [1, 0, 0, 0]
}, {
title: "blue cheese",
content: "the strong taste tends to be well balanced with something a little sweet. preferably candied savory",
tags: [0, 0, 1, 0]
}, {
title: "honey glazed bacon",
content: "candied, good as a savory topping on dessert",
tags: [0, 0, 0, 1]
}, {
title: "Earl's beer and cheese",
content: "review",
tags: [0, 1, 1, 0]
}, {
title: "merlot",
content: "slurp",
tags: [1, 0, 0, 0]
}, {
title: "best wine with seafood",
content: "nothing too fishy - strong wines make it fishier",
tags: [1, 0, 0, 0]
}, {
title: "saison",
content: "pre-industrialized beer, before introduction of hops",
tags: [0, 1, 0, 0]
}, {
title: "saison",
content: "before hops",
tags: [0, 1, 0, 0]
}, {
title: "history of manchego",
content: "unpasteurised sheep cheese, born in the home of Don Quixote - La Mancha, Spain",
tags: [0, 0, 1, 0]
}, {
title: "cheesecake",
content: "history of cheesecake....",
tags: [0, 0, 1, 0]
}, {
title: "proscuitto bruscetta",
content: "noms",
tags: [0, 0, 0, 1]
}, {
title: "bacon",
content: "noms",
tags: [0, 0, 0, 1]
}, {
title: "Cheese better with beer or wine?",
content: "beer better than wine, hands down.",
tags: [1, 1, 1, 0]
}, {
title: "wine and meats",
content: "not as good of an idea as one might think...",
tags: [1, 0, 0, 1]
}, {
title: "the wine-charcuterie landmine",
content: "alcohol tends to accentuate salt...",
tags: [1, 0, 0, 1]
}, {
title: "jamon and cava",
content: "mmmm",
tags: [1, 0, 0, 1]
}, {
title: "Beer and Meats: tale of best friends",
content: "hello there. did you come to read about food? well, i'm off to eat cause i got too hangry writing this post",
tags: [0, 1, 0, 1]
}, {
title: "Marinate meat in Beer",
content: "a nice rausch beer would be great",
tags: [0, 1, 0, 1]
}, {
title: "Hop and Salt",
content: "hoppy beers and salty meats are amazing",
tags: [0, 1, 0, 1]
}, {
title: "a wine for cheesecake",
content: "riesling",
tags: [1, 0, 1, 0]
}, {
title: "cheese fondue recipe",
content: "use wine inside cheese fondue",
tags: [1, 0, 1, 0]
}, {
title: "wines for rich aged cheeses",
content: "manchego-syrah",
tags: [1, 0, 1, 0]
}, {
title: "panchetta, mac & cheese",
content: "nom",
tags: [0, 0, 1, 1]
}, {
title: "meat and cheese plate",
content: "NOM",
tags: [0, 0, 1, 1]
}, {
title: "History of the meat and cheese plate",
content: "NOMNOMNOMNOMNOMNOMNOM",
tags: [0, 0, 1, 1]
}, {
title: "Taste: beer vs wine",
content: "wine has a storied tradition, but as beer brewing has evolved...",
tags: [1, 1, 0, 0]
}, {
title: "beer and cheese guide",
content: "lol you thought this was a real article",
tags: [0, 1, 1, 0]
}
],
hash: [
{
id: 1,
tag: 'wine'
}, {
id: 2,
tag: 'beer'
}, {
id: 3,
tag: 'cheese'
}, {
id: 4,
tag: 'charcuterie'
}
]
};
db.sync({force: true})
.then(function(){
console.log('Dropped old data, now inserting data');
return Promise.map(Object.keys(data), function(name){
return Promise.map(data[name], function(item){
return db.model(name)
.create(item);
});
});
})
.then(function(){
console.log('inserted data');
})
.catch(function(err){
console.error('there was a problem', err, err.stack);
})
.finally(function(){
db.close();
console.log('connection closed');
return null;
});