-
Notifications
You must be signed in to change notification settings - Fork 0
/
db.js
139 lines (130 loc) · 3.19 KB
/
db.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
const Sequelize = require('sequelize');
const sequelize = new Sequelize({
dialect: "sqlite",
storage: "webuy.db"
});
//create the three tables that we need
const itemlist = sequelize.define('Items',
{
id:{
type: Sequelize.INTEGER,
unique: true,
allowNull: false,
primaryKey: true,
},
itemname:{
type: Sequelize.STRING,
allowNull: false
},
picturelink: {
type: Sequelize.STRING,
allowNull: false
},
storeid:{
type: Sequelize.INTEGER,
allowNull: false
},
price:{
type:Sequelize.DOUBLE,
allowNull: false
}
}, {freezeTableName: true, timestamps: false});
const store = sequelize.define('Stores',
{
storename:{
type: Sequelize.STRING,
allowNull: false
},
latitude: {
type: Sequelize.DOUBLE,
allowNull: false
},
longitude: {
type: Sequelize.DOUBLE,
allowNull: false
}
}, {timestamps: false});
const wishlist = sequelize.define('Wishlists',
{
user_id:{
type: Sequelize.INTEGER,
allowNull: false,
},
item_id: {
type: Sequelize.INTEGER,
allowNull: false,
}
}, {timestamps: false});
/*
sequelize
.authenticate()
.then(() => {
console.log('Connection has been established successfully.');
return sequelize.sync({});
}).then(async () => {
await store.create({
storename:"Target Westwood",
latitude: 34.0627963,
longitude: -118.4460309,
id: 1
});
await store.create({
storename:"Marukai",
latitude:34.0479293,
longitude: -118.4662372,
id: 6
});
await store.create({
storename:"Ralphs Westwood",
latitude:34.062651,
longitude: -118.4461308,
id: 3
});
await store.create({
storename:"Nijiya Markey Sawtelle",
latitude:33.9197299,
longitude: -118.4810098,
id: 4
});
await store.create({
storename:"Trader Joes Westwood",
latitude:34.0622696,
longitude: -118.4459629,
id:2
});
await store.create({
storename:"Whole Food",
latitude:34.0664094,
longitude: -118.4498484,
id: 5
});
await store.create({
storename:"Santa Monica Kosher Market",
latitude:34.0560661,
longitude: -118.4573262,
id: 7
});
await store.create({
storename:"Smart & Final",
latitude:34.0531936,
longitude: -118.4721664,
id: 8
});
await store.create({
storename:"Eden L Market",
latitude:34.0552821,
longitude: -118.4737349,
id: 9
});
await store.create({
storename:"Tochal Market",
latitude:34.0604977,
longitude: -118.4559502,
id: 10
})
})
*/
exports["sequelize"] = sequelize
exports["itemlist"] = itemlist
exports["store"] = store
exports["wishlist"] = wishlist