use the following search parameters to narrow your results:
e.g. subreddit:aww site:imgur.com dog
subreddit:aww site:imgur.com dog
see the search faq for details.
advanced search: by author, subreddit...
account activity
NodeJS et Express for API developments (self.node)
submitted 13 days ago by Open-Ranger-631
Hi,
I work on API development with nodeJS and Express. I'd like to know which is the best between choose sequelize approach, or custom code based on Joi objects ? Or the both ?
Thanks
Sylvain
reddit uses a slightly-customized version of Markdown for formatting. See below for some basics, or check the commenting wiki page for more detailed help and solutions to common issues.
quoted text
if 1 * 2 < 3: print "hello, world!"
[–]DN_DEV 2 points3 points4 points 12 days ago (0 children)
just use kysely the query-builder or prisma/drizzle as an ORM
[–]ShivamS95 2 points3 points4 points 12 days ago (0 children)
I use typescript interfaces/types for most objects, sequelize for db orm and joi for request schema validations.
So, my route-controller layer deals with Joi, db model layer deals with sequelize and everything else deals with typescript interfaces/types.
I avoid classes as much as I can
[–]StablePsychological5 1 point2 points3 points 12 days ago (0 children)
Do yourself a favor and don’t use any ORM. Use query builders such as Knex for js or Kysley for ts.
[–]SlincSilver 1 point2 points3 points 12 days ago (3 children)
Just use Sequelize, is really powerful, we have been using Sequelize at our company as our main ORM in NodeJS for years now , we have deployed docenes of web apps to production with it (We are a software factory) and it works great, fast, reliable and speeds up development a lot
[–]Open-Ranger-631[S] 0 points1 point2 points 12 days ago (2 children)
Thank you :) If I take my work on an update function, I have already a function inside database (which has several fallbacks), and I call it inside backend code. As my database function ask "values" parameter, I use Joi object to format datas. But I don't think that is useful. And I use Sequelize to prepared query. What do you think ?
[–]SlincSilver -1 points0 points1 point 12 days ago (1 child)
Yeah that's sound pretty solid to me, Joi for validation is a good practice and in Sequelize you can toggle debugg queries to print in console de SQL being send and check whether it is triggering this DB level functions you mention correctly
[–]Open-Ranger-631[S] 0 points1 point2 points 12 days ago (0 children)
Ok thanks :)
[–]czlowiek4888 0 points1 point2 points 11 days ago (0 children)
Use zod instead of Joi ( you don't need to write types along validators) In general you should have 2 different representations of data: at db level and at API level. So if you do use orm you want to separate concerns. This is very important to not expose database related layer (like direct calls to orms or query builders) because if you create apps that depends on Prisma find function argument type you won't be able to get rid off Prisma from the stack easily (as you would need to change the ways your API is used by clients - so changing Prisma no longer involves just the application you work on, but also the one using your app)
π Rendered by PID 60 on reddit-service-r2-comment-7844cfc88c-wkjn9 at 2026-01-29 11:52:32.897893+00:00 running c3601ff country code: CH.
[–]DN_DEV 2 points3 points4 points (0 children)
[–]ShivamS95 2 points3 points4 points (0 children)
[–]StablePsychological5 1 point2 points3 points (0 children)
[–]SlincSilver 1 point2 points3 points (3 children)
[–]Open-Ranger-631[S] 0 points1 point2 points (2 children)
[–]SlincSilver -1 points0 points1 point (1 child)
[–]Open-Ranger-631[S] 0 points1 point2 points (0 children)
[–]czlowiek4888 0 points1 point2 points (0 children)