-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathgenerate_data.js
50 lines (42 loc) · 1.23 KB
/
generate_data.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
46
47
48
49
50
"use strict";
const firebase = require('firebase');
const Chance = require('chance');
const config = JSON.parse(require('fs').readFileSync('fb_config.json'));
console.log(config);
firebase.initializeApp(config);
const DB = firebase.database();
const chance = new Chance();
const employeesFactory = function(i) {
return {
name: chance.name(),
age: chance.age(),
gender: chance.gender(),
country: chance.country(),
job: i < 100 ? "Frontend Engineer" : "Backend Engineer",
cv: chance.sentence(),
inSearch: i % 2 === 0,
favoriteFramework: i % 2 ? (i > 100 ? "AngularJS" : "Angular2+") : (i > 100 ? "React.JS" : "Vue.JS")
}
};
const employersFactory = function(i) {
return {
name: chance.name(),
country: chance.country(),
address: chance.address({short_suffix: true}),
phone: chance.phone(),
lookingFor: i > 100 ? "Frontend Engineer" : "Backend Engineer",
email: chance.email(),
}
};
let counter = 199;
const employees = DB.ref('employees');
const employers = DB.ref('employers');
for (let i = 0; i < 200; i++) {
Promise.all([
employees.push(employeesFactory(i)),
employers.push(employersFactory(i))
]).then(() => {
--counter;
if (counter === 0) process.exit(0);
});
}