alfateam / orange-orm

The ultimate ORM for Node and Typescript
https://orange-orm.io
ISC License
694 stars 20 forks source link

Benefits over Drizzle ORM? #61

Closed CanRau closed 1 year ago

CanRau commented 1 year ago

Why would I choose rdb over Drizzle ORM, or why are you not using/contributing to Drizzle?

A little impatient maybe but also could be beneficial to other stumbling upon this repo

lroal commented 1 year ago

But it is hard to convince someone to replace their favourite ORM. Just as test drive is essential for truly understanding a car's qualities, experiencing RDB firsthand is the only way to fully grasp its slickness.

RDB is quite old - much older than Drizzle ORM. It's first release on npm was in spring 2014. Before deciding to create our own orm, we considered Sequelize. But we were horrified by the number of bugs and the inconsistent api. I had already experience with creating an inhouse ORM in csharp - so I had a basic idea what the API and the implementation should look like.

The last two years, I have added typescript on top of it. The core is pretty much the same as in 2014. RDB is not widely adopted, but it is very mature, and is running in 100+ instances for major Logistics companies in Norway - receiving thousands of transactions every minute.

CanRau commented 1 year ago

Thanks a lot for the write-up and also the "downsides" 👍🏼

Had no idea it's been around for that long, curious why I never stumbled upon this in all those years 😅

Does rdb currently turn all/most queries into 1 SQL statement like Drizzle does or tries to do? Or is it more like Prisma doing like 6 queries?

Asking because currrently I've got quite a lot of sub-queris, like aggregating related rows as a json array into a field on select.

HTTP transport is interesting though I think I wouldn't currently benefit from it

The API is definitely nice and having to import separate operators is a little annoying, though can give you tree-shaking I guess, but also might be lesser of an issue since Drizzle added queries (docs) like

await db.query.posts.findMany({
  where: (posts, { eq }) => (eq(posts.id, 1)),
  with: {
    comments: {
      where: (comments, { lt }) => lt(comments.createdAt, new Date()),
    },
  },
});

in addition to their existing more SQL like syntax.

Tho definitely need to look more into concurrency (on column level sounds very helpful) & conflict resolutions

lroal commented 1 year ago

And thank's for your interest. It is highly appreciated. ❤️ I have a limited social media network and no "evangelists" to push the framework. Maybe that explains why RDB goes off the radar. I have been playing with the thought of making a youtube video lately. We will see.

RDB create one extra query per one-to-many relation. Except for SQL Server, which can do everything in a single query because it utilizes the FOR JSON PATH operator that can return hierarchical results with extreme performance. Previously, RDB also did sub queries with json aggregate functions for Postgres. But this turned out to be less performant, so I ditched it.