Fix all the config files alignment issues
[samplevnf.git] / VNF_Catalogue / routes / search_max.js
1 /*******************************************************************************
2  * Copyright (c) 2017 Kumar Rishabh and others.
3  *
4  * All rights reserved. This program and the accompanying materials
5  * are made available under the terms of the Apache License, Version 2.0
6  * which accompanies this distribution, and is available at
7  * http://www.apache.org/licenses/LICENSE-2.0
8  *******************************************************************************/
9
10 var express = require('express');
11 var router = express.Router();
12
13 /* Post Controller for Tag autocomplete form */
14 router.post('/', function(req, res) {
15     console.log('here here here here');
16     order_key = req.param('order_key');
17     db_pool.getConnection(function(err, connection) {
18
19         sql_query = 'select * from vnf order by ' + order_key + ' desc limit 8';
20         // TODO find why it works and not above
21         console.log(sql_query);
22         connection.query(sql_query, function (error, results, fields) {
23             console.log(results);
24
25             console.log(results);
26             connection.release();
27             if (error) {
28                 res.end(JSON.stringify({}));
29             } else {
30                 res.end(JSON.stringify(results));    
31             }
32         });
33     });
34 });
35
36 module.exports = router;