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 O’Reilly online learning.

O’Reilly members experience live online training, plus books, videos, and digital content from 200+ publishers.