Posted by on 2022-05-03
  • Web Services

Hey everyone, this is Loren from Donut Team and welcome to another Tuesday Topics blog post!

I've been a bit busy the past couple weeks since I've started a new web development job but, despite that, I've still been chipping away at my various web-related projects for Donut Team.

On that note, I'd like to discuss a bit of what I've been up to with the Donut Team API!

Sequelizing the API

It has been a little while since I've touched on the new users site, in fact the last time I really showed anything was in February.

To be quite honest, I was a little torn on how to proceed forwards on the technical side of things.

My original plan was to create new tables in our database to house user accounts, sessions and more and then migrate all existing data when launching the site but... that proved to make things overly difficult to develop.

My motivation to do so was so we could have better table structures that are more consistent and easy to work with so I began to think of ways to achieve this without having to migrate huge amounts of data.

I tried my hand at writing a number of classes, each representing a different table in the database, that abstracted away the current structure of things but this proved to be overly tedious and hard to maintain.

This kinda tripped me up for a while and it wasn't until I started my new job and ran across a similar, but much more complicated problem, with my work's database. There's lots and lots of data, all linked together, but the structure is not... the greatest.

So surely, I thought, someone else has had this problem before and has come up with a solution.

I spent a good amount of a work day investigating and came across a library called Sequelize which seemed promising. I've heard of the concept of an Object Relational Mapper (what Sequelize is) before but had never tried one out.

Well, after spending the rest of that work day creating models and assocations for the work database, I quickly fell in love with it and how it works. It greatly simplified my workflow for a wide variety of reasons, the most substantial of which being its ability to map object keys to differently named table columns and its ability to extremely easily join tables together.

Needless to say, after that work day, I knew this was also the answer to my problems developing the Donut Team API and profiles site.

That is to say, I've started reimplementing my new API endpoints and am now backing them with the powerful concept of models provided by Sequelize. This should greatly speed up development and render my reasons for wanting to migrate data null and void.

All that said, I'm excited to hopefully have more news about the new user profiles and more very soon. :)


Thanks for reading another one of our Tuesday Topics posts! See you again next week.

- Loren from Donut Team

P.S.: Borb thinks you should listen to this.