DEV Community

Cover image for Node.js uchun ORM tanlaymiz!
Zayniddin Atabaev
Zayniddin Atabaev

Posted on

4 3 2 3 2

Node.js uchun ORM tanlaymiz!

Postda o'zim eng asosiylari deb bilgan 5 ta ORM'ni taqqoslamoqchiman: Prisma, TypeORM, Sequalize, Drizzle va Objection.js. Kyselyni ham qo'shmoqchi edim, lekin u shunchaki query builder bo'lgani uchun uni qo'shmaslikka qaror qildim, lekin u ham yaxshi tool. Quyida turli kategoriyalar bo'yicha o'z fikrlarim bilan bo'lishaman.

Querying

  • Prisma - ✅✅ a'lo darajada! O'zi client library generate qilib beradi va shuni metodlarini ishlatasiz. Query builder yo'q ☹️
  • TypeORM - ✅ yaxshi, o'zini model metodlarini ishlatasiz. Query builder bor lekin unchalik ham zo'r deb bo'lmaydi, shaxsan meni asabimni o'ynaydi
  • Sequelize - ✅ yaxshi, o'zini model metodlarini ishlatasiz. Query builder yo'q ☹️
  • Drizzle - ✅✅ a'lo darajada! Query builder ham bo'r! (batteries included dermidi😄)
  • Objection.js - ✅ yaxshi, chunki u Knex.js!

Type Safety

  • Prisma - ✅✅ a'lo darajada!
  • TypeORM - ✅ yaxshi va asosan o'zizga bog'liq :)
  • Sequelize - ❌ by default support yo'q, bir amallasa bo'ladi
  • Drizzle - ✅✅ a'lo darajada!
  • Objection.js - ⚠️ bor, lekin zo'r emas ☹️

Schema definition

  • Prisma - o'zini .prisma faylida yozasiz. Declarative va sodda
  • TypeORM - TypeScript decoratorlar bilan entitiy classlar yaratasiz, umuman olganda yaxshi
  • Sequelize - object qilib yozasiz, shunchaki norm
  • Drizzle - function'lar ko'rinishida yozasiz, menga yoqadi!
  • Objection.js - class qilib yozasiz, JSON schema bilan input validation qo'shsa bo'ladi, lekin juda unchalik declarative emas

Migration support

  • Prisma - ✅✅ a'lo darajada! prisma cli tool orqali migratsiya yaratish va yuritish mumkin, yoki dev env uchun shunchaki database bilan sync qilsa bo'ladi, migratsiya querylarni generate qilishi yaxshi
  • TypeORM - ⚠️ o'rtacha, cli tool bor lekin unchalik aniq migration querylar generate qilib bermaydi va asosan buggy
  • Sequelize - ✅ yaxshi, chidasa bo'ladi
  • Drizzle - ✅✅ Prisma!
  • Objection.js - ⚠️ Knex orqali qilishgan va migration querylarni o'zingiz yozib chiqishingiz kerak ☹️

Performance

Stupid performance testdan olgan natijalarim (Insertion time of 100k users):

  • Prisma: 2:12.528 (m:ss.mmm)
  • TypeORM: 3:24.115 (m:ss.mmm)
  • Sequelize: 2:05.304 (m:ss.mmm)
  • Drizzle: 👑 1:41.666 (m:ss.mmm)
  • Objection.js: 1:53.682 (m:ss.mmm)

Community & Ecosystem

  • Prisma - ✅✅ a'lo darajada!
  • TypeORM - ✅ yaxshi, lekin maintenance negadir uncha yaxshimasday oxirgi vaqtlarda ☹️
  • Sequelize - ✅ yaxshi, lekin asosan qariyabdi va asta sekinlik bilan undan voz kechishyabdi ☹️
  • Drizzle - ✅ tez o'syabdi, lekin baribir nisbatan yosh
  • Objection.js - ⚠️ unchalik emas to'g'risi, norm

Developer experience, a.k.a. DX (or my own experience🙂)

  • Prisma - ✅✅ a'lo darajada!
  • TypeORM - ✅ yaxshi, lekin yana aytaman, ko'p asab buzadi ☹️
  • Sequelize - ⚠️ unchalik zo'r emas to'g'risi, shunga o'zi undan kechishyabdi deb o'ylayman
  • Drizzle - ✅✅ a'lo darajada!
  • Objection.js - ✅ amallasa bo'ladi :)

Xulosa

Prisma yoki Drizzle ishlating. The end!

Top comments (6)

Collapse
 
lroal profile image
Lars-Erik Roald

Has any of you considered Orange ORM ?
It's reliable, well-documented, and has been around since 2014. It gained TypeScript support in 2023 and is database agnostic. It has full intellisense without code generation.

I am the author, so feel free to ask me anything!

Collapse
 
zayniddindev profile image
Zayniddin Atabaev

Hi! Looks like we have a new and inspiring player out there! I'm excited to check it out really soon :)

Collapse
 
nevodavid profile image
Nevo David

that rundown hits hard - prisma and drizzle always felt smoother for me too. you think it's better to pick something that's growing fast or stick with the old reliable stuff everyone knows?

Collapse
 
zayniddindev profile image
Zayniddin Atabaev

I've been using Prisma for a while now, and I faced several problems with it. There are GitHub issues which are open for several years and that's annoying. But anyways I'm not rushing to migrate totally to Drizzle since I don't have much exp with it, only several pet projects and it already seemed pretty decent. Maybe I'll switch to it in the future after playing around with it more :)

Collapse
 
nevodavid profile image
Nevo David

Perfect, this kinda breakdown is all I ever want before picking tools tbh. Makes me wish I could just swap em in and see which one bugs me less.

Collapse
 
shodlikshomuratov profile image
Shodlik Shomuratov

Assalomu alaykum. Excellent article bro. I love both prisma and drizzle. Drizzle is one of the best.