forked from almighty-ants/pottery-studio
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathseed.js
227 lines (215 loc) · 7.27 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
const { db, Product, User, Cart, CartProduct } = require('./server/db/index');
// console.log('PRODUCT METHODS:', Object.keys(Product.prototype));
// console.log('USER METHODS:', Object.keys(User.prototype));
// console.log('CART METHODS:', Object.keys(Cart.prototype));
const seed = async () => {
try {
await db.sync({ force: true });
// carts
const trueCart = await Cart.create({
isCart: true,
});
const falseCart = await Cart.create({
isCart: false,
});
//users
const john = await User.create({
firstName: 'John',
lastName: 'Jones',
email: '[email protected]',
password: 'testing12345',
address: '91 5th Ave, NY, NY 10011',
});
const noCart = await User.create({
firstName: 'J',
lastName: 'J',
email: '[email protected]',
password: 'jj',
address: '91 5th Ave, NY, NY 10011',
});
const lisa = await User.create({
firstName: 'Lisa',
lastName: 'Forester',
email: '[email protected]',
password: '00',
address: '22 Havemeyer St, Brooklyn, NY 11004',
});
const adminTest = await User.create({
firstName: 'Admin',
lastName: 'User',
email: '[email protected]',
password: '00',
address: '123 Admin Road, Brooklyn, NY 11004',
isAdmin: true,
});
//products
const caraMug = await Product.create({
title: 'Cara Mug',
price: 45,
type: 'mug',
quantity: 5,
colour: 'white',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1614197252740-I1YESWCHM2ZHT7XK0UZT/059+%E2%80%94%E2%80%94+fd+-+mug+-+cara+%E2%80%94+32787.jpg?format=1000w',
});
const eyePatternMug = await Product.create({
title: 'Eye Pattern Mug',
price: 45,
type: 'mug',
quantity: 10,
colour: 'black',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1614197328664-JKS38AV38TW2OU50RKSK/062+%E2%80%94%E2%80%94+fd+-+mug+-+eye+%E2%80%94+32794.jpg?format=1000w',
});
const umaPatternMug = await Product.create({
title: 'Uma Pattern Mug',
price: 45,
type: 'mug',
quantity: 2,
colour: 'white',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1614197303567-Q7A7YGN46S45WOJI83IM/066+%E2%80%94%E2%80%94+fd+-+mug+-+uma+%E2%80%94+32802.jpg?format=1000w',
});
const sandDotVase = await Product.create({
title: 'Sand Dot Vase',
price: 115,
type: 'vase',
quantity: 0,
colour: 'beige',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1653404260004-1SBBC7RPNA33C5S5ULL7/159+-+franca+2022+-+02965.jpg?format=1000w',
});
const costaVase = await Product.create({
title: 'Costa Vase',
price: 98,
type: 'vase',
quantity: 4,
colour: 'black',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1614203435856-ZDRMC24M1L5LZBGPOJDP/052+%E2%80%94%E2%80%94+costa-2-flowers+%E2%80%94+32761.jpg?format=1000w',
});
const fincaVase = await Product.create({
title: 'Finca Vase',
price: 114,
type: 'vase',
quantity: 3,
colour: 'beige',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1614199530414-9P6GMLZ3TSPIZHWKT3QY/091+%E2%80%94%E2%80%94+fd+-+pitcher+-+speckle+%E2%80%94+32868.jpg?format=1000w',
});
const eyePatternBowl = await Product.create({
title: 'Eye Pattern Bowl',
price: 42,
type: 'bowl',
quantity: 5,
colour: 'beige',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1650986197883-EPF59GZQDFKVVS3U2Q08/095+%E2%80%94%E2%80%94+fd+-+ramen+bowl+-+eyes+%E2%80%94+32880.jpg?format=1000w',
});
const umaPatternBowl = await Product.create({
title: 'Uma Pattern Bowl',
price: 42,
type: 'bowl',
quantity: 1,
colour: 'beige',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1650986197886-QGGV0AYL4S1I9PD04SJM/096+%E2%80%94%E2%80%94+fd+-+ramen+bowl+-+uma+%E2%80%94+32881.jpg?format=1000w',
});
const speckledPatternBowl = await Product.create({
title: 'Speckled Pattern Bowl',
price: 42,
type: 'bowl',
quantity: 3,
colour: 'beige',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1650986197887-HQMMAB8IM3RFRZ9CPJVV/098+%E2%80%94%E2%80%94+fd+-+ramen+bowl+-+speckled+%E2%80%94+32884.jpg?format=1000w',
});
const caraPlanetMug = await Product.create({
title: 'Cara Planet Mug',
price: 25,
type: 'planter',
quantity: 4,
colour: 'white',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1598019892065-KZXK2X0QJ9AAXZTMI507/IMG_6677.jpg?format=1000w',
});
const ovalPlanterMug = await Product.create({
title: 'Oval Planter Mug',
price: 25,
type: 'planter',
quantity: 10,
colour: 'black',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1598019897539-3O3TGCUDUBJIAA06YDNU/IMG_6725.jpg?format=1000w',
});
const caraPlanterMug = await Product.create({
title: 'Cara Planter Mug',
price: 25,
type: 'planter',
quantity: 3,
colour: 'white',
imgUrl:
'https://images.squarespace-cdn.com/content/v1/56b7d0fbd51cd4ba74a56129/1598019892065-KZXK2X0QJ9AAXZTMI507/IMG_6677.jpg?format=1000w',
});
const reactiveStonewarePlate = await Product.create({
title: 'Reactive Stoneware Plate',
price: 60,
type: 'plate',
quantity: 4,
colour: 'blue',
imgUrl:
'https://assets.weimgs.com/weimgs/ab/images/wcm/products/202217/0355/img97o.jpg',
});
const swayStonewarePlateSet = await Product.create({
title: 'Sway Stoneware Plate Set',
price: 98,
type: 'plate',
quantity: 2,
colour: 'multi',
imgUrl:
'https://assets.weimgs.com/weimgs/ab/images/wcm/products/202211/0024/sway-salad-plates-o.jpg',
});
const caladonReactiveGlazePlate = await Product.create({
title: 'Celadon Reactive Glaze Plate',
price: 98,
type: 'plate',
quantity: 4,
colour: 'green',
imgUrl:
'https://assets.weimgs.com/weimgs/ab/images/wcm/products/202217/0457/img92o.jpg',
});
await caraMug.addCart(trueCart);
await eyePatternMug.addCart(falseCart);
await umaPatternMug.addCart(trueCart);
await sandDotVase.addCart(trueCart);
await costaVase.addCart(trueCart);
// createCart adds a cart to a user - false by default.
const johnCart = await john.createCart();
await CartProduct.create({
quantity: 1,
cartId: johnCart.id,
productId: costaVase.id,
});
await CartProduct.create({
quantity: 2,
cartId: johnCart.id,
productId: eyePatternMug.id,
});
await lisa.createCart();
} catch (err) {
console.log(err);
}
};
module.exports = seed;
if (require.main === module) {
seed()
.then(() => {
console.log('Seeding success!');
db.close();
})
.catch((err) => {
console.error('Something went wrong!');
console.error(err);
db.close();
});
}