forked from ealeksandrov/NodeAPI
-
Notifications
You must be signed in to change notification settings - Fork 0
/
dataGen.js
41 lines (37 loc) · 1.57 KB
/
dataGen.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
var log = require('./libs/log')(module);
var mongoose = require('./libs/mongoose').mongoose;
var UserModel = require('./libs/mongoose').UserModel;
var ClientModel = require('./libs/mongoose').ClientModel;
var AccessTokenModel = require('./libs/mongoose').AccessTokenModel;
var RefreshTokenModel = require('./libs/mongoose').RefreshTokenModel;
var faker = require('Faker');
UserModel.remove({}, function(err) {
var user = new UserModel({ username: "andrey", password: "simplepassword" });
user.save(function(err, user) {
if(err) return log.error(err);
else log.info("New user - %s:%s",user.username,user.password);
});
for(i=0; i<4; i++) {
var user = new UserModel({ username: faker.random.first_name().toLowerCase(), 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.username,user.password);
});
}
});
ClientModel.remove({}, function(err) {
var client = new ClientModel({ name: "OurService iOS client v1", clientId: "mobileV1", clientSecret:"abc123456" });
client.save(function(err, client) {
if(err) return log.error(err);
else log.info("New client - %s:%s",client.clientId,client.clientSecret);
});
});
AccessTokenModel.remove({}, function (err) {
if (err) return log.error(err);
});
RefreshTokenModel.remove({}, function (err) {
if (err) return log.error(err);
});
setTimeout(function() {
mongoose.disconnect();
}, 3000);