Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const mysql = require('promise-mysql');
- let connection;
- mysql.createConnection({
- host: 'localhost',
- user: 'sauron',
- password: 'theonetruering',
- database: 'mordor'
- })
- .then(function(conn) {
- console.log("Connection ready")
- connection = conn;
- });
- exports.getMarkers = () => {
- return connection.query('select `id` from hobbits where `name`="frodo"')
- .then(function (rows) {
- // Query the items for a ring that Frodo owns.
- let result = connection.query('select * from items where `owner`="' + rows[0].id + '" and `name`="ring"');
- // here NO connection.end();
- return result;
- }).then(function (rows) {
- // returns ring that Frodo owns
- return rows
- }).catch(console.error);
- };
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement