mirror of
https://github.com/sstent/alex_app1.git
synced 2026-01-26 09:02:38 +00:00
lots of work so far-- mostly tidying
This commit is contained in:
31
node_modules/mongoskin/examples/generateId.js
generated
vendored
Normal file
31
node_modules/mongoskin/examples/generateId.js
generated
vendored
Normal file
@@ -0,0 +1,31 @@
|
||||
var redis = require('redis').createClient()
|
||||
, shorten = require('shorten')(redis)
|
||||
, async = require('async')
|
||||
, db = require('./config').db
|
||||
;
|
||||
|
||||
db.bind('user');
|
||||
|
||||
function log(err) {
|
||||
if(err) {
|
||||
console.log(err.stack);
|
||||
}
|
||||
}
|
||||
|
||||
function createUser(user, callback) {
|
||||
|
||||
async.waterfall([
|
||||
function(fn) {
|
||||
shorten.nextId('user', fn);
|
||||
}
|
||||
, function(uid, fn) {
|
||||
user.uid = uid;
|
||||
db.user.save(user, fn);
|
||||
}
|
||||
], callback);
|
||||
|
||||
}
|
||||
|
||||
for(var i = 0; i<10; i++) {
|
||||
createUser({name: 'user' + i}, log);
|
||||
}
|
||||
Reference in New Issue
Block a user