-
Notifications
You must be signed in to change notification settings - Fork 3
/
data-gen.js
45 lines (37 loc) · 1003 Bytes
/
data-gen.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
var faker = require('Faker'),
_ = require('lodash'),
mongoose = require('mongoose'),
log = require('./lib/log')(module),
env = 'development',
config = require('./config/environment')[env],
User = require('./app/models/user');
require('./config/mongoose')(config);
User.remove({}, function(err) {
var user = new User({
email: 'email@email.com',
password: 'password'
});
user.save(function(err, user) {
if (err) {
return log.error(err);
} else {
log.info('New user - %s:%s', user.email, user.password);
}
});
_.forEach(_.range(10), function() {
var user = new User({
email: faker.Internet.email(),
password: faker.Lorem.words(1)[0]
});
user.save(function(err, user) {
if (err) {
return log.error(err);
} else {
log.info('New user - %s:%s', user.email, user.password);
}
});
});
});
_.delay(function() {
mongoose.disconnect();
}, 3000);