Refactor Party & Sequelize CLI Intro
Daily Standup
December 12, 2018
I’ve been having a refactor party working on GFT.
I made all of the models into modules and set up a function for the app to import all models automatically, rather than manually requiring each one as I create it.
I also set it up to make associations between the models. Unfortunately this means I have to drop and re-make several of my data tables. Or maybe not! It seems I can avoid this using Sequelize migrations and the sequelize CLI. That will be my next bit of research.
I also created a new model which has several associations attached. Now that I understand how it works, it’s easy peasy! So the pain was worth the learning :P
Up Next
The Sequelize CLI could have done a lot of this work of setting up the models, db connection, and associations for me automatically. It will also set up the migrations. But since I’ve already done a lot myself, I’m worried bringing this into the project will mess everything up. But it will be worth it in the long run. I wish I knew everything about Sequelize before I started this project!
Here is a good demo I found walking through setting up a Sequelize project using the CLI, and here is the accompanying repo.
EDIT: Also here is a great video demo of sequelize-cli
in action.