How to use the loopback-connector.Transaction 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-datasource-juggler / lib / datasource.js View on Github external
const RelationDefinition = require('./relation-definition.js');
const OberserverMixin = require('./observer');
const jutil = require('./jutil');
const utils = require('./utils');
const ModelBaseClass = require('./model.js');
const DataAccessObject = require('./dao.js');
const defineScope = require('./scope.js').defineScope;
const EventEmitter = require('events').EventEmitter;
const util = require('util');
const assert = require('assert');
const async = require('async');
const traverse = require('traverse');
const g = require('strong-globalize')();
const juggler = require('..');
const deprecated = require('depd')('loopback-datasource-juggler');
const Transaction = require('loopback-connector').Transaction;

if (process.env.DEBUG === 'loopback') {
  // For back-compatibility
  process.env.DEBUG = 'loopback:*';
}
const debug = require('debug')('loopback:datasource');

/*!
 * Export public API
 */
exports.DataSource = DataSource;

/*!
 * Helpers
 */
const slice = Array.prototype.slice;
github strongloop / loopback-connector-oracle / lib / transaction.js View on Github external
// Copyright IBM Corp. 2015,2018. All Rights Reserved.
// Node module: loopback-connector-oracle
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

'use strict';

const g = require('strong-globalize')();
const debug = require('debug')('loopback:connector:oracle:transaction');
const Transaction = require('loopback-connector').Transaction;

module.exports = mixinTransaction;

/*!
 * @param {Oracle} Oracle connector class
 */
function mixinTransaction(Oracle, oracle) {
  /**
   * Begin a new transaction
   * @param isolationLevel
   * @param cb
   */
  Oracle.prototype.beginTransaction = function(isolationLevel, cb) {
    debug('Begin a transaction with isolation level: %s', isolationLevel);
    if (isolationLevel !== Transaction.READ_COMMITTED &&
      isolationLevel !== Transaction.SERIALIZABLE) {
github strongloop / loopback-datasource-juggler / lib / transaction.js View on Github external
// Copyright IBM Corp. 2015,2018. All Rights Reserved.
// Node module: loopback-datasource-juggler
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

'use strict';

const g = require('strong-globalize')();
const debug = require('debug')('loopback:connector:transaction');
const uuid = require('uuid');
const utils = require('./utils');
const jutil = require('./jutil');
const ObserverMixin = require('./observer');

const Transaction = require('loopback-connector').Transaction;

module.exports = TransactionMixin;

/**
 * TransactionMixin class.  Use to add transaction APIs to a model class.
 *
 * @class TransactionMixin
 */
function TransactionMixin() {
}

/**
 * Begin a new transaction.
 *
 * A transaction can be committed or rolled back. If timeout happens, the
 * transaction will be rolled back. Please note a transaction is typically
github strongloop / loopback-datasource-juggler / index.js View on Github external
exports.ModelBuilder = exports.LDL = require('./lib/model-builder.js').ModelBuilder;
exports.DataSource = exports.Schema = require('./lib/datasource.js').DataSource;
exports.ModelBaseClass = require('./lib/model.js');
exports.GeoPoint = require('./lib/geo.js').GeoPoint;
exports.ValidationError = require('./lib/validations.js').ValidationError;

Object.defineProperty(exports, 'version', {
  get: function() { return require('./package.json').version; },
});

const commonTest = './test/common_test';
Object.defineProperty(exports, 'test', {
  get: function() { return require(commonTest); },
});

exports.Transaction = require('loopback-connector').Transaction;

exports.KeyValueAccessObject = require('./lib/kvao');