Advertisement
Guest User

Untitled

a guest
Jun 13th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. const mysql = require('promise-mysql');
  2. let connection;
  3.  
  4. mysql.createConnection({
  5. host: 'localhost',
  6. user: 'sauron',
  7. password: 'theonetruering',
  8. database: 'mordor'
  9. })
  10. .then(function(conn) {
  11. console.log("Connection ready")
  12. connection = conn;
  13. });
  14.  
  15.  
  16.  
  17. exports.getMarkers = () => {
  18. return connection.query('select `id` from hobbits where `name`="frodo"')
  19. .then(function (rows) {
  20. // Query the items for a ring that Frodo owns.
  21. let result = connection.query('select * from items where `owner`="' + rows[0].id + '" and `name`="ring"');
  22. // here NO connection.end();
  23. return result;
  24. }).then(function (rows) {
  25. // returns ring that Frodo owns
  26. return rows
  27. }).catch(console.error);
  28. };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement