promesa sybase
This commit is contained in:
+19
-11
@@ -8,16 +8,24 @@ const db = new Sybase(
|
||||
process.env.SYBASE_PASSWORD
|
||||
);
|
||||
|
||||
db.connect((err) => {
|
||||
if (err) return console.log(err);
|
||||
const alumno = (numeroCuenta) => {
|
||||
return new Promise((resolve, reject) => {
|
||||
db.connect((err) => {
|
||||
if (err) reject(err);
|
||||
db.query(
|
||||
`select * from servicio_social where cuenta = ${numeroCuenta}`,
|
||||
(err, data) => {
|
||||
if (err) reject(err);
|
||||
db.disconnect();
|
||||
console.log(resolve(data));
|
||||
}
|
||||
);
|
||||
});
|
||||
});
|
||||
};
|
||||
|
||||
db.query(
|
||||
'select * from servicio_social where cuenta = 315182934',
|
||||
function (err, data) {
|
||||
if (err) console.log(err);
|
||||
const exec = () => {
|
||||
let a = await alumno('415112132');
|
||||
|
||||
console.log(data);
|
||||
db.disconnect();
|
||||
}
|
||||
);
|
||||
});
|
||||
console.log(a);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user