How to use the loopback-connector.Transaction.READ_COMMITTED function in loopback-connector

To help you get started, we’ve selected a few loopback-connector examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github strongloop / loopback-connector-oracle / lib / transaction.js View on Github external
Oracle.prototype.beginTransaction = function(isolationLevel, cb) {
    debug('Begin a transaction with isolation level: %s', isolationLevel);
    if (isolationLevel !== Transaction.READ_COMMITTED &&
      isolationLevel !== Transaction.SERIALIZABLE) {
      const err = new Error(g.f('Invalid {{isolationLevel}}: %s',
        isolationLevel));
      err.statusCode = 400;
      return process.nextTick(function() {
        cb(err);
      });
    }
    this.pool.getConnection(function(err, connection) {
      if (err) return cb(err);
      if (isolationLevel) {
        const sql = 'SET TRANSACTION ISOLATION LEVEL ' + isolationLevel;
        connection.execute(sql, [],
          {outFormat: oracle.OBJECT, autoCommit: false}, function(err) {
            cb(err, connection);
          });