src/utils.js
/**
 * Begins a transaction for the given model.
 *
 * Similar to Model.beginTransaction but in case the model is using the in-memory data source
 * that has no support for transaction, it returns a dummy transaction object and logs a warning.
 * @param Model - The model to begin a transaction for
 * @param callback - (err, tx)
 */
Begins a transaction for the given model.
Similar to Model.beginTransaction but in case the model is using the in-memory data source
that has no support for transaction, it returns a dummy transaction object and logs a warning.
@param Model - The model to begin a transaction for
@param callback - (err, tx)
Begins a transaction for the given model . Similar to Model . beginTransaction but in case the model is using the in - memory data source that has no support for transaction it returns a dummy transaction object and logs a warning . @param Model - The model to begin a transaction for @param callback - ( err tx )
function beginTransaction(Model, callback) {
	callback = callback || createPromiseCallback();
	if (Model.dataSource.adapter.name === 'memory') {
		debug('Creating a fake transaction object for in-memory connector with model', Model.modelName);
		callback(null, {
			commit(callback) {
				debug('Commit on a fake transaction');
				callback(null);
			},
			rollback(callback) {
				debug('Rollback on a fake transaction');
				callback(null);
			}
		});
	} else {
		Model.beginTransaction({isolationLevel: Model.Transaction.SERIALIZABLE}, (err, tx) => callback(err, tx));
	}
	return callback.promise;
}
function beginTransaction ( Model , callback ) { callback = callback || createPromiseCallback ( ) ; if ( Model . dataSource . adapter . name === 'memory' ) { debug ( 'Creating a fake transaction object for in-memory connector with model' , Model . modelName ) ; callback ( null , { commit ( callback ) { debug ( 'Commit on a fake transaction' ) ; callback ( null ) ; } , rollback ( callback ) { debug ( 'Rollback on a fake transaction' ) ; callback ( null ) ; } } ) ; } else { Model . beginTransaction ( { isolationLevel : Model . Transaction . SERIALIZABLE } , ( err , tx ) => callback ( err , tx ) ) ; } return callback . promise ; }
Begins a transaction for the given model.
Begins a transaction for the given model .