promise learn
This commit is contained in:
27
tools/app/promise-learn/build/index.js
Normal file
27
tools/app/promise-learn/build/index.js
Normal file
@ -0,0 +1,27 @@
|
||||
"use strict";
|
||||
const mariadb = require('mariadb');
|
||||
let conn;
|
||||
mariadb.createConnection({
|
||||
host: 'database',
|
||||
user: 'heroes',
|
||||
password: 'test123',
|
||||
database: 'heroes'
|
||||
})
|
||||
.then(conn => {
|
||||
conn.query("SELECT * FROM hero")
|
||||
.then((rows) => {
|
||||
console.log(rows);
|
||||
return rows;
|
||||
})
|
||||
.then((res) => {
|
||||
console.log(res);
|
||||
conn.end();
|
||||
})
|
||||
.catch(err => {
|
||||
console.log(err);
|
||||
conn.end();
|
||||
});
|
||||
})
|
||||
.catch(err => {
|
||||
console.log('not connected');
|
||||
});
|
Reference in New Issue
Block a user