You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
With the advent of functions with insert/update/delete, it's very tempting to be able to define functions on types themselves.
Schema
type Movie {
title: str;
multi actors: Actor;
multi reviews: Review;
getWithRating: function() {
select Movie {
title,
actors: {
name
},
rating :=math::mean(.reviews.score)
}
}
}
And then:
with m := (select Movie limit1), select m.withRating()
I know it's possible to do a similar behavior by passing a movie as the first parameter. But it's extremely convenient this way. And it would enable moving more of the business logic to the database with a minimal cognitive overhead.
If a schema has 40 types and each type has 2-3 functions:
Currently, a developer would have to browse through 80-120 functions to find one to use.
But with this, he wouldn't have to think about it. Plus it would be possible to get autocomplete in queries and client libraries ...
I don't have any stats, but I don't think people define functions all that much either in Postgres nor other databases. Maybe because ORMs don't expose that in a nice way, or maybe they'd rather implement stuff in the programming language.
I think this would be aligned with EdgeDB because it enables offloading more to the database while preserving programming language ergonomics.
The text was updated successfully, but these errors were encountered:
With the advent of functions with insert/update/delete, it's very tempting to be able to define functions on types themselves.
Schema
And then:
I know it's possible to do a similar behavior by passing a movie as the first parameter. But it's extremely convenient this way. And it would enable moving more of the business logic to the database with a minimal cognitive overhead.
If a schema has 40 types and each type has 2-3 functions:
I don't have any stats, but I don't think people define functions all that much either in Postgres nor other databases. Maybe because ORMs don't expose that in a nice way, or maybe they'd rather implement stuff in the programming language.
I think this would be aligned with EdgeDB because it enables offloading more to the database while preserving programming language ergonomics.
The text was updated successfully, but these errors were encountered: