Skip to content

Instantly share code, notes, and snippets.

@cranic
Created March 21, 2014 13:37
Show Gist options
  • Save cranic/9686415 to your computer and use it in GitHub Desktop.
Save cranic/9686415 to your computer and use it in GitHub Desktop.
// 1 - try / catch doesn't work with async codes, so you don't need to use
// 2 - You need to add a callback to be trigered when everything had run
module.exports = {
createNewUser: function (user, callback){
connection.query('INSERT INTO users (email, first_name, last_name, password) VALUES ("?", "?", "?", "?")', [user.email, user.first_name, user.last_name, user.password], function(err, result) {
// We will pass the error and the result to the function
callback(err, result);
});
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment