-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
33 lines (23 loc) · 818 Bytes
/
Copy pathindex.js
File metadata and controls
33 lines (23 loc) · 818 Bytes
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
const app = require('express')();
const bodyParser = require('body-parser');
app.use(bodyParser.json())
app.get('/', (req, res)=> {
res.send('This is my updated Nodejs projet');
});
app.post('/getIndexes', (req, res)=> {
var indexingQuery = `ALTER TABLE ${req.body.tablename} `;
const columns = req.body.columns;
columns.forEach((element, index) => {
if(index === 0) {
indexingQuery = indexingQuery + ` ADD INDEX \`idx_${element}\`(\`${element}\`)`;
} else {
indexingQuery = indexingQuery + `, ADD INDEX \`idx_${element}\`(\`${element}\`)`;
}
});
const output = {
tableName: req.tableName,
indexingQuery: indexingQuery + ';'
}
res.send(output)
})
app.listen(3000, ()=> console.log('Server is up and running'));