I'm using Sequelise with node.js, and I have a feeling the paradigm I'm using to modify objects is not working well, as my code is getting messy rather quickly.The function User.createOrMerge is designed to be called after a successful social auth (Google, Facebook etc.), with kwargs being the social auth token to check against the user (e.g. { googleId: some-oauth-token }).I seem to be writing a lot of code to deal with the overhead of using promises. Is there a way to do this more elegantly or is this my life now?User.findByUsername = function(username, success, error){  User.findOne({    where: {      username: username    }  }).then(function(user){    success && success(user);  }, function(){    error && error();  });};User.findByEmail = function(email, success, error){  User.findOne({    where: {      email: email    }  }).then(function(user){    success && success(user);  }, function(){    error && error()  });}User.createOrMerge = function(username, email, kwargs, success, failure){  // if user with kwargs exists, return that  User.findOne({    where: kwargs  }).then(function (user) {      if(user){        success && success(user);      }else{        // if email address exists, merge user        User.findByEmail(email, function(user){          if(user){            user.updateAttributes(kwargs).then(function(){               success && success(user);            });          }else{            // if username exists, modify this one            User.findByUsername(username, function(user){              if(user){                username += UUID();              }              // finally create a new user              kwargs['username'] = username;              kwargs['email'] = email;              User.create(kwargs).then(function(user){                success && success(user);              }, function(){                failure && failure();              });            }, function(){              failure && failure();            });          }        }, function(){          failure && failure();        });      }  }, function(){    failure && failure();  });}
Creating a user via social auth, merging and modifying appropriately
javascript;node.js