-
Notifications
You must be signed in to change notification settings - Fork 0
/
dummydata.js
85 lines (63 loc) · 3.49 KB
/
dummydata.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
const { pool } = require('./utils/config.js');
const { Client } = require('./utils/db.js');
exports.fillDummydata = async function (req, res) {
const client = await Client();
try {
await client
.query("INSERT INTO credentials (user_id,password,admin_level) VALUES ('admin_01','admin_01',2)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO credentials (user_id,password,admin_level) VALUES ('agent_01','agent_01',1)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO credentials (user_id,password,admin_level) VALUES ('voter_01','voter_01',0)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO credentials (user_id,password,admin_level) VALUES ('voter_02','voter_02',0)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO credentials (user_id,password,admin_level) VALUES ('voter_03','voter_03',0)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO election (election_id,title,address,active) VALUES ('01','Lok Sabha','Kerela',1)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO election (election_id,title,address,active) VALUES ('02','Panchayat','Uttar Pradesh',1)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO candidate (candidate_id,election_id,name,gender,party,party_logo,votes) VALUES ('01','01','Ganesh','Male','BJP','KAMAL',0)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO candidate (candidate_id,election_id,name,gender,party,party_logo,votes) VALUES ('02','01','Dinesh','Male','AAP','Broom',0)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO candidate (candidate_id,election_id,name,gender,party,party_logo,votes) VALUES ('03','01','Shweta','Female','Congress','Hand',0)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO candidate (candidate_id,election_id,name,gender,party,party_logo,votes) VALUES ('04','02','Ramesh','Male','BJP','KAMAL',0)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO candidate (candidate_id,election_id,name,gender,party,party_logo,votes) VALUES ('05','02','Ghanshyam','Male','AAP','Broom',0)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
await client
.query("INSERT INTO candidate (candidate_id,election_id,name,gender,party,party_logo,votes) VALUES ('06','02','Manoj','Male','Congress','Hand',0)")
.then(res => console.log("Data added"))
.catch(err => console.log(`${err}`));
res.status(200).send("Data filled");
await client.release();
} catch (err) {
res.status(503).send(`Error : ${err}`);
}
}