Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- let express = require('express');
- let mysql = require('mysql')
- let app = express();
- let connection = mysql.createConnection({
- user: "norbi",
- password: "Iqevm7SDa6mZegZa",
- host: "145.239.82.137",
- port: 3306,
- database: "mrc",
- });
- app.set('port', process.env.PORT || 5000);
- app.get('/', function(req, res){
- connection.connect();
- connection.query(perform_query([62,63]), function (err, rows, fields) {
- if (err){
- throw err;
- }
- let data = {}
- for (let i in rows){
- data['Array['+ i +']'] = rows[i];
- i++;
- }
- res.json(data)
- });
- connection.end();
- });
- function perform_query(...product_ids){
- return 'SELECT products.id, products.code, products.category,'+
- 'categories.name_pol, categories.name_eng, categories.name_rus, categories.name_ger '+
- 'FROM products '+
- 'INNER JOIN categories ON categories.id = products.category '+
- 'WHERE products.id IN ('+ product_ids +');';
- }
- app.listen(app.get('port'), function(){
- console.log('http://127.0.0.1:5000');
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement