Soooooo much progress this week on GFT! I have been putting in looong days due to the milestone date (due today) I set last week; the intent was to complete:
- 2 feature functionalities completed
- a basic UI
- an admin dashboard
- sending a live URL of the alpha version out for some feedback
Soooo…yeah a bit ambitious for one week, even with a holiday weekend. I learned my lesson! So now I am just focusing on point number one to complete before going back to work on Tuesday. I think I’ll get there!
This is what massively slowed things down. I already ran into some long ‘learning sessions’ (shall we call it) on some of my model associations and I thought I’d gained a pretty good understanding of how Sequelize needs you to establish and access relationships between models. And I had, for
It turns out
belongsToMany associations are a different ballgame all together. The documentation is sparse, and open issues, blog posts, etc show that other people have run into similar problems without including a very good resolution or solution. I can’t say I fully understand it still myself, but here are some things I did learn to be true:
Always include an
as alias definition when association models with
The docs specify that a
through definition is required, but I found that the
as definition also seems to be required. The reason is that Sequelize auto-generates an alias for the join table, and you have to include that alias when querying either model if you want to reference the other:
Strangely, whatever the auto-generated alias is, it’s not easily accessible (or at least, I couldn’t find it). I tried so many things (so, so many) but the association wouldn’t work without an alias, and no logical guess of the auto-generated alias worked, nor could I figure out how to display the alias anywhere. So the best way to get around this was to set the alias, and then call it everywhere.
The Sequelize CLI migration tool is awesome. Though it could use better documentation (and for that matter should really be update to ES6, among other necessary updates), it saved a lot of effort and time when I decided to rename some tables and reconfigure my database structure a little bit. I definitely recommend using it if you’re going to use Sequelize.
Another thing I learned/reconfirmed that’s not related to Sequelize is the value of planning. When working on one of the new features, I got a bit lost. So I needed to step back and look at the big picture to elucidate what actually needed working on. This led to the aforementioned db structure reconfiguration, and I think it will be better for the app design in the long run.
That said, it took a couple hours of literally just sitting and thinking to get to this point, and to map everything out. So let’s just say I’m really grateful for these days off work!
I’m looking at Tailwind CSS as I look ahead to implementing a UI for the site. It seems like a bit of a learning curve there, and would definitely lock me into using it if I do, so still exploring this.
Also I have a mentor session later this week about implementing tests into the app…finally! Gotta prep for that.
Oh yeah, and happy Easter!
Finish my milestone target before the week is up!