Skip to content

Instantly share code, notes, and snippets.

@totuworld
Last active August 29, 2015 14:26
Show Gist options
  • Save totuworld/947426948b96143d7f76 to your computer and use it in GitHub Desktop.
Save totuworld/947426948b96143d7f76 to your computer and use it in GitHub Desktop.
사용자 정보를 등록한다.
/* POST 사용자 아이디를 등록할 때 사용한다. */
router.post('/add/:userID', function(req, res) {
//아이디 중복 확인
function CheckIsHaveID(callback) {
models.usercore.find({where:{id:req.params.userID}})
.then(function(findUserCoreData) {
callback( !(findUserCoreData == null || findUserCoreData == undefined) );
});
}
//아이디를 등록한다.
function CreateAccount(callback) {
models.usercore
.create({id:req.parmas.userID, gems:20, coins:1000, hearts:5})
.then(function(createdUserCore) {
callback(null, createdUserCore.no);
});
}
async.series([
CheckIsHaveID,
CreateAccount
], function(err, results) {
if(err) {
//err:아이디가 중복되는 경우.
res.send('exist');
}
else {
//완료 결과 전송.
res.send('done0'+results[1]);
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment