Step 4

Let's add a new file, sampleUsers.js to the scripts folder with the following content:

const faker = require("faker");
const db = require("../server/data/db");
const UserDao = require("../server/data/UserDao");

async function createSampleUsers(role) {
  try {
    await db.connect();

    const users = new UserDao();
    const user = await users.create({
      username: faker.internet.userName(),
      password: faker.internet.password(),
      role: role,
    });
    console.log(user);
  } catch (err) {
    console.log(err);
  }
}

createSampleUsers("CLIENT");
createSampleUsers("CLIENT");
createSampleUsers("ADMIN");

Run the sampleUsers.js file to create a few sample users!

node scripts/sampleUsers.js

Check the database to ensure the sample users have been created.