Created
October 11, 2013 20:41
-
-
Save mulderp/6941704 to your computer and use it in GitHub Desktop.
User signup with Node and Redis
This file contains 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
function createUser(raw, success_cb, fail_cb) { | |
var userId; | |
console.log("enter"); | |
async.waterfall([ | |
function(cb) { | |
// Increase | |
client.hincrby('users', 'count', 1, cb); | |
}, | |
function(id, cb) { | |
// Higher Scope a userId variable for access later. | |
userId = id; | |
console.log(userId); | |
// Set | |
client.hmset('user:'+id, | |
'username', raw.username, | |
'password', raw.password, | |
'email', raw.email, | |
cb); | |
}, | |
function(write, cb) { | |
client.hmget('user:'+userId, 'username', 'email', cb); | |
} | |
], function(err,read){ | |
if (err) { | |
fail_cb(err); | |
} | |
success_cb(userId, read); | |
}) | |
}; | |
Author
mulderp
commented
Oct 12, 2013
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment