001-staffMembers.js 791 B

12345678910111213141516171819202122232425262728
  1. "use strict";
  2. const faker = require("faker");
  3. const { generateUniqueList } = require("../seedersUtils");
  4. const { seedValue, seedRowCounts } = require("../src/config/seeders");
  5. const TABLE_NAME = "sl_staff_members";
  6. module.exports = {
  7. up: async (queryInterface, Sequelize) => {
  8. faker.seed(seedValue);
  9. const uniqueNames = generateUniqueList(
  10. seedRowCounts.staffMembers,
  11. () => `${faker.name.firstName()} ${faker.name.lastName()}`
  12. );
  13. const data = uniqueNames.map((name, index) => ({
  14. id: index + 1,
  15. name,
  16. email: `${name.split(" ").join(".")}@example.com`,
  17. }));
  18. await queryInterface.bulkInsert(TABLE_NAME, data, {});
  19. },
  20. down: async (queryInterface, Sequelize) => {
  21. await queryInterface.bulkDelete(TABLE_NAME, null, {});
  22. },
  23. };