Skip to content

Instantly share code, notes, and snippets.

@WitkowskiMichau
Created May 28, 2021 15:21
Show Gist options
  • Save WitkowskiMichau/acbccc5e2d83110878e8981f943ba8e5 to your computer and use it in GitHub Desktop.
Save WitkowskiMichau/acbccc5e2d83110878e8981f943ba8e5 to your computer and use it in GitHub Desktop.
const Chance = require('chance')
const chance = new Chance('user-admin-mock-data')
const generateUser = (id) => ({
id: chance.guid(),
name: chance.name()
})
const generateUsers = () => ids.map(generateUser)
module.exports = (db = null) => {
const users = generateUsers()
if (db) {
const updateDB = (key, data) => db.get(key).push(...data).write()
updateDB('users', users)
}
return {
users
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment