Last active
November 7, 2020 14:15
-
-
Save danidr7/f4e87ff2548db48001584e4b2466a913 to your computer and use it in GitHub Desktop.
A script for generate fake data on MongoDB
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let occupations = ['programmer', 'tester', 'manager', 'analyst', 'product owner'] | |
let randomStringNum = (min, max) => (Math.random() * (max - min) + min).toString().split('.')[0] | |
let randomString = () => Math.random().toString(36).substring(2) | |
for(let i=0; i<10000; i++) { | |
let randomName = randomString() | |
let randomCPF = randomStringNum(0, 99999999999) | |
let randomOccupation = occupations[randomStringNum(0, occupations.length)] | |
let randomPhone = randomStringNum(0, 9999999999999) | |
let randomAge = parseInt(randomStringNum(0, 100)) | |
let person = { | |
name: randomName, | |
cpf: randomCPF, | |
occupation: randomOccupation, | |
phone: randomPhone, | |
age: randomAge | |
} | |
db.person.insert(person) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment