Skip to content

Instantly share code, notes, and snippets.

@pkosiec
Last active October 13, 2020 20:15
Show Gist options
  • Save pkosiec/64d73aa89ea714cbd9b86366db426259 to your computer and use it in GitHub Desktop.
Save pkosiec/64d73aa89ea714cbd9b86366db426259 to your computer and use it in GitHub Desktop.
Example MongoDB document with randomization
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