Skip to content

Isolation level with transtion #985

@sapkal-manish

Description

@sapkal-manish

If I have decided to use "beginTransaction" in my code, How to set isolation level for the transaction?

Here is my code :

pool.getConnection(function(err, connection) {
   if (err) {
       //log error to file
       return callback(err, null);
   }
   else {
       connection.beginTransaction(function(err) {
            if (err) { return callback(err, null); }
            connection.query({ 'sql' : query, 'timeout': timeout}, function(err, rows, fields) {
                 connection.release(); //send back to pool
                 if (err) {
                    connection.rollback(function() {
                        //log error to file
                        return callback(err, null);
                    })
                 }
                connection.commit(function(err) {
                    if (err) {
                        connection.rollback(function() {
                            self.delParams(aParam);
                            return callback(err, null);
                        });
                    }
                    return callback && callback(null, rows);
                });
            })
       })
   }
}) 

Now how to set isolation level like 'read commit' in my case? Do you have some example?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions