Table of Contents
ToggleDrizzle vs Prisma: worthy rivals
Today we will talk about such a confrontation as Drizzle vs Prisma. We will find out what advantages and disadvantages Drizzle and Prisma have, compare their functionality and features of each. To be honest, I am not an expert in the IT field and coding, but I can write excellent articles and select the information needed for them. So, let’s not delay – let’s begin.
Prisma vs Drizzle is a fairly powerful confrontation between two ORMs. Let’s remember what ORM is. The abbreviation hides Object-relational mapping, which means “a programming technology that connects databases with the concepts of object-oriented programming languages”. In more understandable terms, ORM is a layer between the database and the code that the programmer writes, which allows objects created in the program to be added to/received from the database.
Drizzle is another of the most popular TypeScript frameworks on the market. Drizzle works with any database, with any serverless drivers and lives on the edge.
As for Prisma, it is a tool that allows you to work with relational (for example, PostgreSQL, MySQL, SQL Server) and non-relational (MongoDB) databases using JavaScript or TypeScript without using SQL (although this option is available).
Drizzle and Prisma Migrations: what is known about them
Prisma vs Drizzle – let the showdown begin!
A migration is the process of creating and reproducing a set of database schema changes to bring the database to a new state. Prisma and Drizzle handle migrations in the same way, generating SQL files based on model definitions and providing a CLI to execute them. The SQL files can be modified before execution, allowing you to perform custom database operations on either system.
Advantages of Prisma and Drizzle
As every software has its strengths and weaknesses, so every ORM is gifted with significant pros and cons.Bo th Prisma and Drizzle have significant advantages that allow them to compete for a place in the sun, as well as significant disadvantages that force programmers to switch to other frameworks. Let’s start with Drizzle.
The main advantages of Drizzle:
- Much faster than Prisma (at least with sqlite – uses bettersqlite3).
- Quite a simple syntax, which at the same time resembles pure SQL.
- The presence of a chat bot based on Artificial Intelligence in the documentation is an undeniable advantage of Drizzle.
- The mental model is quite simple and intuitive.
- Text input is very reliable and works quite smoothly during normal operation.
- The schema is written in typescript, not some DSL that is quite awkward to work with.
The main advantages of Prisma:
- More mature than Drizzle.
- Quite reliable in production if you configure it correctly with timeouts.
- Simple query syntax.
- Does not block the thread.
- Better experience in defining relationships.
- Has a larger community than Drizzle.
- Offers a powerful API with safe typing, as well as a GraphQL API for querying data.
Drizzle and Prisma Weaknesses
Drizzle vs Prisma is a pretty strong duo, each boasting obvious advantages. However, both contenders have their weaknesses that can be disappointing. Let’s define them together.
Drizzle Cons:
- Irreversible migrations, which make it difficult to experiment with local development of a complex problem.
- Constraint checks are not supported.
- Less mature ORM compared to Prisma.
- Smaller community compared to Prisma, which means less chance to find solutions to your problem.
- No support for relational filtering with the query API.
- Does not support Mongo.
- Does not have its own GraphQL package.
- Sometimes just generates empty migration files (for manual migration), because it cannot migrate some changes for you.
- Cannot rename migration files (would like to be able to change the format to date instead of an incrementing index and a random combination of names).
Cons of Prisma:
- It is heavy.
- Many users complain about poor support, which is slow to resolve issues.
- Due to its architecture, it is not compatible with Cloudlare Workers.
- No support for associations (ie: a method added via an extension only works with a model, not when using select or include).
- Prisma’s constant polling puts a strain on the database.
- Prisma does not handle very complex queries well.
- It is slower than Drizzle.
- It does not use SQL.
- It does not work in edge environments and does not work well if you are deploying to serverless.
- Prisma does not do joins in the database, it does joins using its own prisma rust engine. This leads to inefficiencies at the application level and additional overhead that the database must handle.
Drizzle ORM vs Prisma Discussion on Reddit
A Reddit user asked other users what they liked better – Prisma or Drizzle. Here are some responses:
“In my opinion, Prisma has a high chance of failing unless they make significant changes. The main problem is that they don’t address the problems of their users. There are many long-standing issues with Prisma that remain unsolved or seemingly ignored (e.g. validations, soft delete, nanoid, multi-file schema, hooks/events, custom fields, rollback migrations, and more). Their responses to these issues have often been very poor, with some issues ignored for years. Furthermore, the decision to write Prisma in Rust and rely on a separate server for queries is pretty bad… While their marketing and documentation are good, the actual ORM is falling apart quickly…”
“For faster development and proof of concept, go with Prisma. If you want full-featured, performant SQL with a bit of typescript flavor, go with Drizzle.”
“I prefer Prisma as I’ve been using it in production at my company for a little over a year now, as well as in one of my personal projects. The TypeScript support is fantastic, it syncs your database with your schema, is very actively supported, and has an active community. Every issue I’ve had has been answered within hours by someone in their Slack channel. They now have a Discord too.”
Drizzle vs Prisma: who won?
All ORMs, like people themselves, have their advantages and disadvantages. It is difficult to say objectively which is better: Prisma or Drizzle. They are both type-safe and aimed at increasing the efficiency of developers when working with a JavaScript/TypeScript database.
To make the right choice in favor of one or another ORM, it is very important to determine the requirements of the project, such as the desired feature set, database support, and performance requirements.
Try working with both Drizzle and Prisma. Only after using both will you make the right choice for yourself. Good luck!