-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathdatabase.js
65 lines (59 loc) · 1.61 KB
/
database.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
const sequelize= require('sequelize');
const Op = sequelize.Op;
const db= new sequelize(
'covid19',
'root',
'admin',
{
dialect: 'mysql',
host: 'localhost'
}
)
//table to store user details
const users= db.define('users',{
username: {
type: sequelize.STRING,
allowNull: false,
unique: true
},
password: {
type: sequelize.STRING,
allowNull: false
},
first_name: sequelize.STRING,
last_name: sequelize.STRING,
email_id: sequelize.STRING,
mobile_number: sequelize.STRING,
address: sequelize.STRING,
profile_picture: sequelize.STRING
});
//table to store donations
const donations= db.define('donations',{
username: sequelize.STRING,
subject: sequelize.STRING,
name: sequelize.STRING,
email_id: sequelize.STRING,
mobile_number: sequelize.STRING,
address: sequelize.STRING,
Medicalquantityapprox: sequelize.STRING,
Clothesquantityapprox: sequelize.STRING,
Booksquantityapprox: sequelize.STRING,
FoodPacketsquantityapprox: sequelize.STRING,
Groceriesquantityapprox: sequelize.STRING,
quantityapprox: sequelize.STRING,
status: sequelize.STRING
});
function admin_callback(){
db.query(`INSERT IGNORE INTO users (username,password,first_name,last_name,email_id,mobile_number,profile_picture)` +
`VALUES ('admin','9073326812','Aanshuman','Sharma','[email protected]','9426375332','000.png')`);
}
db.sync().then(function(){
console.log('Database is syncronized');
admin_callback();
});
module.exports = {
Op,
db,
users,
donations
};