Live data from Hacker News

DenoDB

github.com

211–220 of 220 posts

Re: DenoDB

#211

Earlier quoted context omitted.

> devs started to get afraid of changing schema or code that touched database because that could create runtime errors as opposed to compilation errors. Being afraid to refactor is really bad and piles up quickly as technical debt Yes, this definitely happens! Like somebody else said, tests can cover a lot of this. But of course they aren't perfect. Where I'm at right now, we have multiple microservices reading from…

> Where I'm at right now, we have multiple microservices reading from the same database Like, all from the same base tables or each with their own schema with service-specific views? Also, isn't shared-DB integration by-definition incompatible with “microservices”, which are isolated and sovereign over their own data?

From the same base tables. And yes, it is very incompatible with the definition of a microservice and causes plenty of horrible issues.

I didn't say it was good architecture. It's a remnant of when we were a startup in "move fast break things" mode (we have since been acquired) and as an org paying down tech debt has never been a priority so we're left with a lot of bad decisions that we have to live with (to the point where it's a miracle when we actually ship any meaningful features...)

Re: DenoDB

#212
post #198

Earlier quoted context omitted.

I mean universal in the sense that going from mysql to postgres is really not a big shift. I have worked mainly with postgres/mysql but i would imagine i would be up and running at full speed in days/a few weeks with mssql if i ever chose it for a project. sure there are syntax differences, but the "how do i do this" translates very well across databases.

How do you make event triggers in MySQL? How do you make a system-versioned table/query in PostgreSQL? How do you port regular expressions to MS SQL Server? How do you set up an exclusion constraint on a range type (without race conditions or invalid data) in anything except Postgres? Most relational databases fit niches that the other don't. No one RDBMS is best, but they are most certainly not interchangeable. Even…

Well if you are comparing non-standard database features you are out of luck. Im talking about the 95% CRUD stuff that you do. Basic selects/joins/aggregations etc.

Its super rare i see the need to actually change the underlying database from say postgres to mysql. And in this scenario you are still screwed if you did use a ORM, with database X only features.

My point was basic SQL knowledge transfers between databases for the bread and butter 95% of things you need to do.

Re: DenoDB

#213

Every time we discuss an ORM project, someone is bound to complain about ORMs in general. I have a small suggestion: please try ORMs in different languages. A lot of the power of an ORM depends on the language. Your ORM may not be the same as my ORMs - Django ORM, SQLAlchemy, Pony ORM. Try them and you will know why. I will wait. From my limited understanding, the language needs to allow reflecting and manipulating y…

Used ORMs in many different languages, from ActiveRecord, Hibernate, EntityFramework, SQLAlchemy, Bookshelf.js, GORM, and Ecto (Ecto was the best, ActiveRecord was the most "feature rich", Hibernate makes me cry, and EntityFramework is OK so long as you give Microsoft a lot of money). For dynamic languages the downsides are increased runtime cost over simply writing and executing sql and doing the mapping yourself, a…

I don't think EntityFramework Core (on NET Core) costs all that much?

Re: DenoDB

#214

Earlier quoted context omitted.

> ORMs are tools. If you ignore the power tools you have available, you're going to end up as obsolete as someone who insists on still building houses or cabinets using only hand tools. Yes, of course it can be done. But it takes 100-1000x longer, and the results are often not as good. I'm very skeptical that there are any productivity benefits to ORMs. Note you can forego the ORM and still use a query builder to off…

I've been doing this as my $DAYJOB for the last five years. Your examples/predicted catastrophes are straw men that I've never seen in reality myself--though I've heard reports of Rails/ActiveRecord having issues similar to what you describe. Maybe that's the real problem you're worried about? RoR sucks. We can agree on that. In the code I've been working with, though? An ORM can have annoying limitations, but doesn'…

We contributed some type definitions a couple years back to node-sql, which is a very lightweight query builder: https://github.com/brianc/node-sql

Re: DenoDB

#215
post #213

Earlier quoted context omitted.

Used ORMs in many different languages, from ActiveRecord, Hibernate, EntityFramework, SQLAlchemy, Bookshelf.js, GORM, and Ecto (Ecto was the best, ActiveRecord was the most "feature rich", Hibernate makes me cry, and EntityFramework is OK so long as you give Microsoft a lot of money). For dynamic languages the downsides are increased runtime cost over simply writing and executing sql and doing the mapping yourself, a…

I don't think EntityFramework Core (on NET Core) costs all that much?

To get the full power of EntityFramework, with all the cool code and graph generation, I think you need a paid version of Visual Studio and SSMS, although I could be wrong. Either way costing anything at all already puts it at a disadvantage compared to the others I mentioned.

Re: DenoDB

#216
post #209

Earlier quoted context omitted.

Pgtyped looks really cool. So does Zapatos. But my current gig has an absolute non-negotiable business requirement to support multiple database backends. Specifically SQL Server and MySQL in addition to PostgreSQL. Additionally: Not seeing any way to take the schema info from either of the above and have it crank out a full GraphQL server code base. Check out my linked comment if you want more details, but I'm seriou…

I think you're highlighting features that are not inherent to ORMs but seem to be packaged with the ORM you use. There are libraries that will transform a Postgres or MySQL schema into a GraphQL API. I don't keep up with them, but the names Postgraphile and Hasura come to mind. I also think that you're saying that (Type)ORM is a good solution because it saves you a lot of time, but are you a typical user? Your case s…

I'm actually using Prisma.io right now.

TypeORM has another similar solution.

Postgraphile looks cool, but ... you're writing your custom handler in PostgreSQL script. This strikes me as suboptimal for debugging and general developer productivity. Otherwise, you're right, it's a similar solution. Which actually contradicts your assertion that I'm highlighting features "packaged with the ORM I use."

Hasura...looks like a black box that you'd have very little direct control over, and if they went out of business, you'd be totally screwed. I'm very firmly against lock-in with no fallback. Been there. Don't want to do it again.

Regardless, I'm only six-months-new on the GraphQL version of this stack. Before that I was using FeathersJS with Sequelize: Similar to GraphQL only with more traditional REST endpoints and less built-in JOINing between tables. FeathersJS actually has more flexibility in querying a single table, and adding indirect JOINs was possible/generalizable across your whole API with a few lines of code, but what wasn't as clean was the security model for who could see what.

Another similar stack is LoopbackJS. I'm sure there are more.

So it's really, really not that of a niche case. I've used a similar approach again and again for pretty much every backend project that needed a CRUD API. Every one of those projects I touched probably had 1/100th the amount of raw code required compared to the traditional wasteful approach.

Re: DenoDB

#217
post #209

Earlier quoted context omitted.

I think you're highlighting features that are not inherent to ORMs but seem to be packaged with the ORM you use. There are libraries that will transform a Postgres or MySQL schema into a GraphQL API. I don't keep up with them, but the names Postgraphile and Hasura come to mind. I also think that you're saying that (Type)ORM is a good solution because it saves you a lot of time, but are you a typical user? Your case s…

I'm actually using Prisma.io right now. TypeORM has another similar solution. Postgraphile looks cool, but ... you're writing your custom handler in PostgreSQL script . This strikes me as suboptimal for debugging and general developer productivity. Otherwise, you're right, it's a similar solution. Which actually contradicts your assertion that I'm highlighting features "packaged with the ORM I use." Hasura...looks li…

Please note you can add custom handlers in PostGraphile using JS as well as SQL; we have an extensive plugin API, but if you just want to use SDL and resolvers we’ve a plugin generator for that: https://www.graphile.org/postgraphile/make-extend-schema-plu...

Re: DenoDB

#218

Earlier quoted context omitted.

I'm actually using Prisma.io right now. TypeORM has another similar solution. Postgraphile looks cool, but ... you're writing your custom handler in PostgreSQL script . This strikes me as suboptimal for debugging and general developer productivity. Otherwise, you're right, it's a similar solution. Which actually contradicts your assertion that I'm highlighting features "packaged with the ORM I use." Hasura...looks li…

Please note you can add custom handlers in PostGraphile using JS as well as SQL; we have an extensive plugin API, but if you just want to use SDL and resolvers we’ve a plugin generator for that: https://www.graphile.org/postgraphile/make-extend-schema-plu...

Awesome...maybe?

Does it support TypeScript? Because I'm not going back to dynamic types for nontrivial code. Ever.

Does it support debugging? Because having a real interactive debugger with source mapping, ideally integrated into VS Code, is another minimum bar for me to consider it a viable platform.

If yes to both, then: Awesome! I'll keep it in mind for future projects where it's appropriate.

Re: DenoDB

#219
post #208

Earlier quoted context omitted.

OK, that's awesome. But type safety is only part of the equation. Automatic CRUD or GraphQL code generation and/or other abstraction such that you never need to write basic CRUD code ever again? That should be a minimal software engineering best practice at this point, and yet we have tons of people insisting on writing every single query, either as a SQL query directly or using a query builder. It's on the order of…

I have read through a bunch of your comments and it frankly doesn't even sound like you are doing database queries for an application: it sounds like you were tasked with creating a very general purpose API endpoint for application developers. You thereby to me don't even seem to be having a use case for an "ORM", so I am extremely confused? It seems like you wanted a tool that let you describe an intended API surfac…

Good question! To which I respond with another question: Why not both? ;)

Actual example code from my current project (with the actual object type anonymized by renaming it to "thing"):

    const result = await prisma.thingInstance.findMany({
        where: {
            thingTypeId: {
                in: thingTypes.map((id) => id.childThingTypeId),
            },
            thingInstanceChildren: {
                none: {
                    parentThingId: {
                        equals: args.parentThingId,
                    },
                },
            },
        },
        orderBy: {
            thingTypeId: "desc",
        },
        take: 120,
    });
Returns an array of ThingInstance objects. It can also return joined relations (giving you the "Object Relational" part of ORM), or filter on joins, or what have you.

It's because Prisma (in this case) is an ORM that fully understands the data architecture that you can layer a full automation/code generation/GraphQL server on top of it. Not all ORMs have this feature, but you mostly need to start with an ORM in order to bootstrap this functionality.

I guess you could do what you're describing by creating tons of highly specialized code given a schema without adding the ORM/query building features--but adding the layer that gives you a Data Mapper pattern ORM is a tiny amount of additional effort at that point.

I did mention elsewhere: Some people seem to think that the ActiveRecord pattern is the only "ORM" approach, but Data Mapper is another approach--and one that is usually referred to as another view strategy of an ORM. [1]

[1] https://culttt.com/2014/06/18/whats-difference-active-record...

Re: DenoDB

#220
post #58

Earlier quoted context omitted.

I’ve been using https://prisma.io lately and I love it. It builds a Db client right from your db schema including Typescript typings. I don’t consider it an ORM in the classical sense. I see it more as a query builder.

Prisma looks great as someone who lives in Typescript land. Have you been using it "in anger", are there any limitations you've run into that its worth keeping in mind? I'm going to give it a shot on my personal project.

Hi! Sorry for the late response. I've been using it "in a lot of pleasure".

Bear in mind I've just used it for personal side projects, nothing too critical.

I recommend you give it a try and form your own opinion.

Feel free to get in touch!

Post reply on HN