Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
post-service.js
const oracledb = require('oracledb');
const uuidv4 = require('uuid/v4');
oracledb.outFormat = oracledb.OBJECT;
oracledb.fetchAsString = [oracledb.CLOB];
oracledb.autoCommit = true;
module.exports = class PostService {
    constructor(){ }
    static async init() {
        console.log('Creating connection pool...')
        await oracledb.createPool({
            user: process.env.DB_USER,
            password: process.env.DB_PASSWORD,
            connectString: process.env.CONNECT_STRING,
        });
        console.log('Connection pool created')
        return new PostService();
    }
    async closePool() {
        console.log('Closing connection pool...');
        try {
            await oracledb.getPool().close(10);
            console.log('Pool closed');
        } catch(err) {
            console.error(err);
        }
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment