Created
May 9, 2013 22:23
-
-
Save chilts/5551069 to your computer and use it in GitHub Desktop.
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
// this needs to be read from the DB on startup | |
var userId = 1; | |
function putUser(user, cb) { | |
// am making this up for the purposes of demonstration - don't know what your use-case is | |
userId++; | |
user.id = userId; | |
var ops = [ | |
{ type: 'put', key: 'sequence:userId', value : userId }, | |
{ type: 'put', key: user.nick, value: user } | |
]; | |
db.batch(ops, function (err) { | |
if (err) return console.log('Ooops!', err) | |
console.log('Great success dear leader!') | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment