Skip to content
GitLab
    • Explore Projects Groups Snippets
Projects Groups Snippets
  • /
  • Help
    • Help
    • Support
    • Community forum
    • Submit feedback
  • Sign in
  • User Account User Account
  • Project information
    • Project information
    • Activity
    • Labels
    • Members
  • Repository
    • Repository
    • Files
    • Commits
    • Branches
    • Tags
    • Contributors
    • Graph
    • Compare
    • Locked Files
  • Issues 0
    • Issues 0
    • List
    • Boards
    • Service Desk
    • Milestones
    • Iterations
    • Requirements
  • Merge requests 0
    • Merge requests 0
  • CI/CD
    • CI/CD
    • Pipelines
    • Jobs
    • Schedules
    • Test Cases
  • Deployments
    • Deployments
    • Environments
    • Releases
  • Packages and registries
    • Packages and registries
    • Package Registry
    • Infrastructure Registry
  • Monitor
    • Monitor
    • Metrics
    • Incidents
  • Analytics
    • Analytics
    • Value stream
    • CI/CD
    • Code review
    • Insights
    • Issue
    • Repository
  • Wiki
    • Wiki
  • Snippets
    • Snippets
  • Activity
  • Graph
  • Create a new issue
  • Jobs
  • Commits
  • Issue Boards
Collapse sidebar
  • m4lab_tv1
  • User AccountUser Account
  • Merge requests
  • !118
An error occurred while fetching the assigned milestone of the selected merge_request.

pick connection from pool before transaction

  • Review changes

  • Download
  • Email patches
  • Plain diff
Merged Wolfgang Knopki requested to merge MLAB-566-fix into testing 3 years ago
  • Overview 0
  • Commits 1
  • Pipelines 0
  • Changes 1

Fix problem with connection pool not providing beginTransaction as a function

  • Wolfgang Knopki @knopkiwg assigned to @knopkiwg 3 years ago

    assigned to @knopkiwg

  • Wolfgang Knopki @knopkiwg mentioned in commit 31d44844 3 years ago

    mentioned in commit 31d44844

  • Wolfgang Knopki @knopkiwg merged 3 years ago

    merged

  • Loading
  • Loading
  • You're only seeing other activity in the feed. To add a comment, switch to one of the following options.
Please register or sign in to reply
Compare
  • testing (base)

and
  • latest version
    e00f0382
    1 commit, 3 years ago

1 file
+ 42
- 39

    Preferences

    File browser
    Compare changes
functions/methods.ts
+ 42
- 39
  • View file @ e00f0382

  • Edit in single-file editor

  • Open in Web IDE


@@ -3,62 +3,65 @@ import dbconn = require('../config/dbconn')
@@ -3,62 +3,65 @@ import dbconn = require('../config/dbconn')
var methods = {
var methods = {
// ===================== user db =====================
// ===================== user db =====================
registerNewUser: function(data:any, callback:any) {
registerNewUser: function(data:any, callback:any) {
dbconn.user.beginTransaction(function(err:any) { // START TRANSACTION
dbconn.user.getConnection(function(err:any, thisconn){
if (err) { throw err }
thisconn.beginTransaction(function(err:any) { // START TRANSACTION
// insert profile
if (err) { throw err }
dbconn.user.query('INSERT INTO user SET ?', data.profile, function (err:any, results:any, fields:any) {
// insert profile
if (err) {
thisconn.query('INSERT INTO user SET ?', data.profile, function (err:any, results:any, fields:any) {
return dbconn.user.rollback(function() {
throw err
});
}
let newUserId:number = results.insertId
// set password
var credentialData:any = {
user_id: newUserId,
password: data.password
}
dbconn.user.query('INSERT INTO credential SET ?', credentialData, function (err:any, results:any, fields:any) {
if (err) {
if (err) {
return dbconn.user.rollback(function() {
return thisconn.rollback(function() {
throw err
throw err
});
});
}
}
// set default user-project-role
let newUserId:number = results.insertId
var projectRoleData:any = {
// set password
project_id: 1, //M4_LAB
var credentialData:any = {
role_id: 2, // USER
user_id: newUserId,
user_id: newUserId
password: data.password
}
}
dbconn.user.query('INSERT INTO user_project_role SET ?', projectRoleData, function (err:any, results:any, fields:any) {
thisconn.query('INSERT INTO credential SET ?', credentialData, function (err:any, results:any, fields:any) {
if (err) {
if (err) {
return dbconn.user.rollback(function() {
return thisconn.rollback(function() {
throw err
throw err
});
});
}
}
// MLAB-129: INSERT verification token
// set default user-project-role
let verificationData:any = {
var projectRoleData:any = {
user_id: newUserId,
project_id: 1, //M4_LAB
token: data.verificationToken
role_id: 2, // USER
 
user_id: newUserId
}
}
dbconn.user.query('INSERT INTO verification SET ?', verificationData, function (err:any, results:any, fields:any) {
thisconn.query('INSERT INTO user_project_role SET ?', projectRoleData, function (err:any, results:any, fields:any) {
if (err) {
if (err) {
return dbconn.user.rollback(function() {
return thisconn.rollback(function() {
throw err
throw err
});
});
}
}
// COMMIT
// MLAB-129: INSERT verification token
dbconn.user.commit(function(err:any) {
let verificationData:any = {
 
user_id: newUserId,
 
token: data.verificationToken
 
}
 
thisconn.query('INSERT INTO verification SET ?', verificationData, function (err:any, results:any, fields:any) {
if (err) {
if (err) {
return dbconn.user.rollback(function() {
return thisconn.rollback(function() {
throw err
throw err
})
});
}
}
 
// COMMIT
 
thisconn.commit(function(err:any) {
 
if (err) {
 
return thisconn.rollback(function() {
 
throw err
 
})
 
}
 
})
})
})
})
})
})
});
});
});
});
callback(err)
 
});
callback(err)
callback(err)
})
})
},
},
@@ -208,4 +211,4 @@ var methods = {
@@ -208,4 +211,4 @@ var methods = {
}
}
};
};
export = methods
export = methods
\ No newline at end of file
Assignee
Wolfgang Knopki's avatar
Wolfgang Knopki
Assign to
0 Reviewers
None
Request review from
Labels
0
None
0
None
    Assign labels
  • Manage project labels

Milestone
No milestone
None
None
Time tracking
No estimate or time spent
Lock merge request
Unlocked
0
0 participants
Reference:
Source branch: MLAB-566-fix

Menu

Explore Projects Groups Snippets

Dies ist die Gitlab-Instanz des Transferportals der Hochschule für Technik Stuttgart. Hier geht es zurück zum Portal