Eric Crooks - Profile Photo

Eric Crooks

Software Engineer (Raleigh, NC)
Back to all journal entries

Bonfire Sessions: Snuky's New Application Details Page

Introducing the Application Details page—the command center for every opportunity, built for deeper insights and total control

Summary

I have a ton of scrap wood (woodworking is my hobby) and time to spare in my job search. So here I am coding Snuky by the bonfire—finishing a new feature that enables me to take control of each job opportunity and refine my process for other job opportunities.

Issues Encountered

Drizzle ORM

I chose Drizzle ORM for Snuky because I like exploring new technologies. I've used Prisma, Sequelize, and Postgres.js for most of my JavaScript career and don't have issues with them, but I prefer not to rely on the same tools repeatedly. Drizzle is new to me and I want to see how intuitive it is and how it compares to what I've already used.

Interoperability

When I migrated the project from using SQLite to Postgres, I had to change my Drizzle ORM queries. For example, here's some code showing how to get my resumes using SQLite and Postgres implementations. I'm using drizzle-orm@~0.45.2 here btw.

const db = drizzle(/* configs */)
 
// SQLite impl
const result = await db
  .select()
  .from(resumes)
  .where(eq(resumes.id, Number(id)))
  .get();
 
// Postgres impl
const results = await db
  .select()
  .from(resumes)
  .where(eq(resumes.id, Number(id)))
 
const result = results?.[0]

As you can above, the SQLite implementation can return a result in a single chained call. The Postgres implementation does not have a .get() method, so I had to figure out how to get a single result from the query—make the query and get the first element of the possibly returned array.

My expectation with interoperable code here is: devs should be able to switch their database without having to modify their code. Granted, the code is not far off from being able to do this, but being a little off can degrade the developer experience (if you add missing documentation to this, then it's degraded a bit more).

Being on drizzle-orm v0.x, I did try using drizzle-orm v1.x and it didn't make a difference with interoperability. I still had to change my code.

Migrations

I had a difficult time trying to get migrations to work. The error outputs aren't clear and sometimes there are no errors. Sometimes drizzle-kit just fails silently, and I'm not the only one experiencing these issues. See the related issue and pull request below.

I spent about 4 hours trying to get migrations to work for me. I even tried using the internal migrate() function and couldn't get that to work for me (still encountered silent failures).

Documentation

There's a documentation-driven article on GitHub somewhere that states (words to this effect), "If it's not documented, it doesn't exist. If it's documented incorrectly, it's broken." In Drizzle ORM's case, there are many things undocumented, yet the product seems feature-rich. I do wish their documentation was more verbose and broken down Barney style like Team Treehouse videos because I feel this product can be very intuitive. I did fork the repo with plans to write some documentation for them, but that's a low priority for me right now.

job searchaiatssnukybonfires

Looking to connect?