ryanrasti
Hey everyone – after coming off of 3 years building with Ecto, I’ve been working non-stop on Typegres, a new query builder that strongly aligns with Ecto’s philosophy around composabilty & purity.
The core, novel idea: write class methods that compile directly to composable SQL (try it in the playground)
// Extend your models
class Post extends posts.asClass<Post>() {
// by writing methods
trendingScore() {
return this.likes.divide(this.ageInHours().plus(2)); // → SQL, not JS!
}
}
// and use them anywhere in your queries:
await Post.select((p) => ({
content: p.content,
trending: p.trendingScore(),
}))
.orderBy((p) => p.trendingScore()) // Everything composes into a single query, just like Ecto
What you’ll appreciate coming from Ecto:
- Composability: Everything is composable SQL expressions (and since it’s Typescript, it’s fully typed too)
- Purity: no N+1 queries or obscure magic – just a translation layer meant to maximize the synergy between TypeScript and Postgres
What makes Typegres different:
- True OOP in SQL: Encapsulate business logic in methods (
post.trendingScore()) instead of scattered helper functions (and relations and graph-based querying naturally follow as a result of the composability). This a huge step towards resolving the object-relational impedance mismatch - Postgres, Postgres, Postgres: coverage for all 3000+ built-in functions/operators without SQL strings (with coverage for all statements in the works)
Github:
https://github.com/ryanrasti/typegres
As a huge admirer of Ecto, I’d love to hear what this community thinks. Does this approach to unifying objects and SQL resonate with you?
Trending in Discussions
As the title says, please share what you’ve been up to with Elixir. Whether that’s been learning it, looking into it, making stuff with i...
New
Hey there,
It’s been more than a year since we started using LiveView as our main UI library and building a whole library of UI componen...
New
I am happy to introduce the very α version of the new programming language compiled to BEAM.
Welcome Cure.
It has literally three kille...
New
Quite interesting article Google brought me. Didn’t find any mentions about it here.
What do you think in general? Would you use togethe...
New
:warning: Security advisory: Decimal DoS vulnerability
A vulnerability has been published for decimal where very large exponents can cau...
New
It would be helpful to have a list of companies worldwide that hire engineers without prior experience in Elixir. Often, it can be quite ...
New
What IDE or editor are you using for Elixir development?
Personally, I use Zed, and I really like it, but sometimes I wish there were a ...
New
Other Trending Topics
Hi there! We created Gust: A task orchestrator inspired by Airflow.
For those who have never heard about Aiflow, it’s a Python-based wor...
New
Beam Bots (or just BB for short) is a framework for building fault-tolerant robotics applications in Elixir using familiar OTP patterns. ...
New
Xamal is a deployment tool for Elixir apps that deploys native releases to bare metal servers over SSH. It’s a port of GitHub - basecamp/...
New
Corex is an accessible, unstyled UI component library for Phoenix that integrates Zag.js state machines using Vanilla JavaScript and Live...
New
With AI doing more of the implementation work, I’ve been wondering how much coding I should deliberately keep doing myself.
My main conc...
New
Aludel - LLM Evaluation Workbench
Aludel is an embeddable Phoenix LiveView dashboard for evaluating and comparing LLM prompts across mult...
New
Categories:
Sub Categories:
Forums
Popular Tags
- #ecto
- #liveview
- #troubleshooting
- #learning-elixir
- #library
- #deployment
- #erlang
- #testing
- #genserver
- #mix
- #absinthe
- #remote-other
- #otp
- #plug
- #how-to-question
- #macros
- #postgres
- #elixirconf
- #channels
- #exunit
- #discussion
- #code-sync
- #podcasts
- #javascript
- #onsite
- #dialyzer
- #docker
- #authentication
- #umbrella
- #full-time-contract
- #podcasts-by-brainlid
- #ecto-query
- #elixirconf-us
- #ai
- #blog-post
- #elixir-ls
- #phoenix_html
- #iex
- #graphql
- #genstage
- #websockets
- #supervisor
- #advent-of-code
- #distillery
- #processes
- #api
- #forms
- #hex
- #security
- #metaprogramming










Showing Posts 1 to 2- Show Best Posts
- Show All (oldest first)
- Show All (newest first)
billylanchantin
Very cool! I think Ecto gets a lot right, so I’m glad to see others working on the problem from that direction rather than ORMs.
Probably there won’t be a ton of traction on this forum about the OOP aspects of Typegres since Elixir isn’t object-oriented. But since you brought up Ecto, how does Typgres compare to Linq?
From what I understand, the Ecto developers drew inspiration from Linq. And I believe Linq was originally for C#, an OOP language, so there may be more overlap in terms of design goals.
ryanrasti
Thanks! I didn’t know about LINQ inspiring Ecto, it definitely is an inspiration for Typegres.
The design goals of Typegres and LINQ are similar in the sense of providing a query builder that feels idiomatic in the host language (Typescript/C# respectively). In fact the fluent API looks pretty similar in both (similar to pipe-based query building – e.g.,
|> wherein Ecto)The similarities mostly end there though. LINQ was designed to be generic over arbitrary datasources (e.g., in memory, xml files, etc.) Typegres is designed to feel like you’re importing 100% of Postgres, with additional idiomatic TypeScript on top.
Since you know Ecto well - are there specific features or patterns from it that you think are essential to get right or additional avenues you’d think are worth exploring?