Last active
August 29, 2015 14:01
-
-
Save leonguyen/ece705456036f8cc27e1 to your computer and use it in GitHub Desktop.
Transactions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| conn.beginTransaction(function(err) { | |
| if (err) { | |
| throw err; | |
| } | |
| conn.query('INSERT INTO gluer_topic SET ?', data, function(err, result) { | |
| if (err) { | |
| console.error(err); | |
| conn.rollback(function() { | |
| throw err; | |
| }); | |
| } | |
| var data1 = { | |
| UID: uid, | |
| TID: result.insertId, | |
| UTAuthority: 'C', | |
| UTAccess: 'RWVC' | |
| }; | |
| console.log('[createTopic] data:' + data1); | |
| conn.query('INSERT INTO gluer_ut SET ? ', data1, function(err, result1){ | |
| if(err) { | |
| console.error(err); | |
| conn.rollback(function() { | |
| throw err; | |
| }); | |
| return next(err, -1); | |
| } | |
| conn.commit(function(err) { | |
| if (err) { | |
| conn.rollback(function() { | |
| throw err; | |
| }); | |
| } | |
| console.log('[createTopic] Create Topic OK'); | |
| return next(false, result.insertId); | |
| });//Commit | |
| });//gluer_ut | |
| });//gluer_topic | |
| });//Transaction |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment