Skip to content

Instantly share code, notes, and snippets.

@gaurangrshah
Created November 20, 2020 06:45
Show Gist options
  • Save gaurangrshah/ac876987ba25906fbb86173287dce7ce to your computer and use it in GitHub Desktop.
Save gaurangrshah/ac876987ba25906fbb86173287dce7ce to your computer and use it in GitHub Desktop.
#db #utils #js #seed #data
function seed (length, schema) {
return new Array(length) //create a new array with length(num) of 'undefined' values
.fill(1) // convert 'undefined' values to the number 1
.map((_, i) => ({schema})) // map over the array length(num) of times and output an item based on schema
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment