Skip to content

Instantly share code, notes, and snippets.

@chilts
Created May 9, 2013 22:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chilts/5551069 to your computer and use it in GitHub Desktop.
Save chilts/5551069 to your computer and use it in GitHub Desktop.
// 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