The Great Sequelizer
Today, we moved from strict PostgreSQL and SQL to working with Sequelize — a module that improves the usability of a relational database in the context of JavaScript.
Because strict SQL doesn’t work that efficiently with JS, Sequelize acts as an effective mediator-of-sorts between the two on their way to the database (which, for us has been PostgreSQL), and results in a more readable code and an easier way to maintain your databases.
Our instructor provided a visual of the flow of this process on the whiteboard, which I found helpful:
JavaScript → Sequelize → SQL → PostgreSQLSequelize is an example of an ‘ORM’ (Object Relational Mapper) — a technology that enables the access and manipulation of objects (i.e., “data”) between systems that aren’t inherently compatible. ORMs do this by allowing programmers to develop a sort of “map” of a database’s structure and contents and create coinciding code that allows for more practical and efficient access and use of that data.
For our first application of this sort of data mapping, we revisited our ‘to-do’ list project from two weeks back, and tried to rework the file structure and requirements to store newly input “to-do” items into our database and then access, update, and output those items in different formats based on whether or not those items were marked ‘complete’ using Sequelize.
I’ve been having a hard time wrapping my head around the concept of this sort of ‘virtual database’ approach and don’t yet have the command I need to get the code outputting the way I’d like, so I’ll hold off on sharing the results until it’s looking a little better 🤓.
Song of the Day: “Glue” by Fickle Friends
