Seeding foreign key data

The challenge of adding users is that we have already introduced a foreign key constraint to the database. You can follow these instructions to learn how to get it working:

  1. We use the Sequelize CLI to generate an empty seeders file, as follows:
sequelize seed:generate --name fake-users --seeders-path src/server/seeders
  1. Fill in the following code to insert the fake users:
'use strict';module.exports = {  up: (queryInterface, Sequelize) => {    return queryInterface.bulkInsert('Users', [{      avatar: '/uploads/avatar1.png',      username: 'TestUser',      createdAt: new Date(),      updatedAt: new Date(),    },    {      avatar: '/uploads/avatar2.png',      username: 'TestUser2',      createdAt: new Date(),      updatedAt: new Date(),    }],    {});  }, down: (queryInterface, ...

Get Hands-On Full-Stack Web Development with GraphQL and React now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.