diff --git a/index.js b/index.js index 398a30b..5e57a6a 100644 --- a/index.js +++ b/index.js @@ -47,14 +47,6 @@ GRANT ALL PRIVILEGES ON blog_mermsemr_com.* TO 'wroot'@'10.0.0.52'; */ -var con = mysql.createConnection({ - host: "10.10.33.60", // ip address of server running mysql - user: "wroot", // user name to your mysql database - password: "wroot@#Chi3fW0rks.52", // corresponding password - database: "blog_mermsemr_com" // use this database to querying context - }); - - const price_list = [ { id: 1, description: 'Free',price: '0.00',currency : 'NG', provider_id : '1' }, { id: 2, description: 'Basic Encounter',price: '100.00',currency : 'NG', provider_id : '1' }, @@ -63,27 +55,22 @@ const price_list = [ ]; app.get('/', function (req, res) { - - //res.status(200).send(price_list); - // client.query('SELECT * FROM members', (err, res) => { - // console.log(err, res) - // client.end() - // }) - - let findPostsQry = "SELECT p1.id AS id, p1.*, wm2.meta_value FROM wp_mermsemrposts p1 LEFT JOIN wp_mermsemrpostmeta wm1 ON (wm1.post_id = p1.id AND wm1.meta_value IS NOT NULL AND wm1.meta_key = '_thumbnail_id' ) LEFT JOIN wp_mermsemrpostmeta wm2 ON (wm1.meta_value = wm2.post_id AND wm2.meta_key = '_wp_attached_file' AND wm2.meta_value IS NOT NULL ) WHERE p1.post_status='publish' AND p1.post_type='post' ORDER BY p1.post_date DESC LIMIT 9"; + let findPostsQry = `SELECT p1.id AS id, p1.*, wm2.meta_value FROM wp_mermsemrposts p1 + LEFT JOIN wp_mermsemrpostmeta wm1 ON + (wm1.post_id = p1.id AND wm1.meta_value IS NOT NULL AND wm1.meta_key = '_thumbnail_id' ) + LEFT JOIN wp_mermsemrpostmeta wm2 ON + (wm1.meta_value = wm2.post_id AND wm2.meta_key = '_wp_attached_file' AND wm2.meta_value IS NOT NULL ) + WHERE p1.post_status='publish' AND p1.post_type='post' + ORDER BY p1.post_date DESC LIMIT 9`; - - -con.query(findPostsQry, function (err, result, fields) { + con.query(findPostsQry, function (err, result, fields) { // if any error while executing above query, throw error if (err) throw err; // if there is no error, you have the result console.log(result); res.status(200).send( [{payload: result}]); -}); - - + }); })