February 2019
Intermediate to advanced
204 pages
4h 52m
English
We are going to use the faker library (https://github.com/marak/Faker.js/) to create a list of users that we will be using in our REST API. Create a seed.js file inside server/helpers/seed.js, as follows:
if ( process.argv.length <= 2 || !['Admin', 'User', 'Doctor'].includes(process.argv[2])) { console.log(`The script need a params: ${__filename}`); console.log('Params valid: Doctor'); process.exit(-1);}const faker = require('faker');require('../helpers/prototype');const Model = require('../models');const run = param => { console.log(`Script runing: ${param}`); switch (param) { case 'Doctor': return Promise.all( [...new Array(100).keys()].map(() => Model.users.createData( { password: '123123', confirmPassword: '123123', email: ...Read now
Unlock full access