Skip to content

Instantly share code, notes, and snippets.

@maiquealmeida
Created January 26, 2018 12:32
Show Gist options
  • Save maiquealmeida/68db91295f0dda1c9380c2c1c7377008 to your computer and use it in GitHub Desktop.
Save maiquealmeida/68db91295f0dda1c9380c2c1c7377008 to your computer and use it in GitHub Desktop.
Estrutura basica para consultas utilizando NodeJS e Oracle.
let connection = null;
try {
connection = await oracledb.getConnection(config.database);
let result = await connection.execute("...", {}, {outFormat: oracledb.OBJECT});
...
} catch (err) {
// Envia uma resposta JSON relatando o erro.
databaseException(err, res, err.message);
} finally {
// Release the connection
if (connection) {
await connection.release(
function (err) {
if (err) {
console.error(err.message);
} else {
// console.log("Connection released");
}
});
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment