Jonnie Grieve Digital Media: Blog

Home
by on 2nd March, 2021 - 4:29pm (0)

Blog: R6D74: #100DaysOfCode (More Posts)

I decided on a change of topic today. I’ve had a tutorial on the go for Data Relationships with Sequelize.js on the go for some time. I’d run into an issue where running Sequelize Queries brought an EagerLoading Exception. So Sequelize was up and running but it ran into a fatal error at a certain point.

Although I have to say the error messaging was very helpful and pointed me in the right direction. The code I’d written looked like it was trying to write SQL code that created database relationships I’d forgotten to set the foreign key on one of the database models.

I forgot to set the foreign key for the Movie model

 

Movie.associate = (models) => {

    Movie.belongsTo(models.Person, {
    foreignKey: {
        fieldName: 'directorPersonId',
    allowNull: false,
    }
  });
};

You’ll also have noticed I’ve posted code snippets from time to time in this blog. I’ve also spent some time today trying to get some syntax highlighting applied as a plugin to make those snippets stand out. I’ve tested various plugins to try out highlighting but this causes more harm than good.  Any syntax highlighting the plugin might be trying to apply does not work and when updating or posting a page something blocks the link from showing the updated page.

So that effort will continue.

This post has been assigned to the following categories

    Leave a Reply

    Your email address will not be published. Required fields are marked *