Last active
October 13, 2020 20:15
-
-
Save pkosiec/64d73aa89ea714cbd9b86366db426259 to your computer and use it in GitHub Desktop.
Example MongoDB document with randomization
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
const { getObjectId } = require("mongo-seeding"); | |
const names = ["John", "Joanne", "Bob", "Will", "Chris", "Mike", "Anna", "Jack", "Peter", "Paul"]; | |
const min = 18; | |
const max = 100; | |
module.exports = names.map(name => ({ | |
firstName: name, | |
age: Math.floor(Math.random() * (max - min + 1)) + min, | |
_id: getObjectId(name), | |
})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment