Show HN: Better-SQL - Generate sql query from syntax like GraphQL and EdgeDB
better-sql.surge.sh
better-sql.surge.sh
Some key features:
* select with nested syntax and auto generate join-table statements
* auto add table name to each column
It comes with a "typescript-playground-style" online demo so you can try it without any setup ;)
Most importantly, what are the consequences of creating a custom language that only works in a narrow situation?
Instead this language is converted into plain SQL, so it can work with any existing SQL databases, including mysql, postgres, mssql, sqlite, e.t.c.
The handy part of this language is it allows selecting columns from multiple tables using nested syntax without writing join table statements explicitly.
The main point is that developers don't want to learn a bespoke language tied to a single tool. SQL relates to the underlying math and is known by many many people, even non-developers.
One of the design goal for this language is to enable developers that are not familiar with sql to get into work that involves database with less effort.
This tool is like syntax sugar on the select part, the where, order by, groups by, having are the same as standard sql (except they can be distributed with corresponding table select, and they can appear in any order, which should be easier to dev with)
One problem you will run into is putting a LIMIT on relationship queries
You can't use a limit for this
select post [
id
title
# Can't generate simple LIMIT here
user { nickname } limit 2
]
limit 5If you mean use sub-query. You may write something like below
select post [
id
title
user { nickname }
]
limit 5
where user_id in (
select user [ id ]
order by created_at desc
limit 2
)
Thanks for your interest, welcome more questions and ideas :)