- read

Xata SQL over HTTP + ORM

Yusril Ihsanul Alim 184

If I were to be employed at Xata … this is a lighweight session, written to be a non-technical matter, this is my second article about Xata. check out my first article at Cutting-Edge Serverless Database 🦋.

Today, we’re going to release new technical blog, how to make this right? immediately start typing : SQL over HTTP and ORM integrations

I questioning why would we support SQL over our libs? I mean basically, our libs are already support standard parameter for basic operations.

Do I have to build a custom proxy and support ORM integrations through a multiple SDK platform?

These are definition of insanity. Xata are getting out of control, they does not stop release new features after released. Through hype-driven-development, “SQL over HTTP” is like a bullish trend.

We’re working on multiple xata plug-in to give our best to community. Our biggest challenge are support O(n) ORM library, and somehow we should mixing those library with Xata functionality through our wrapper.

In order to enabling Xata abilities, we design a custom plug-in for ORM (wrapper) and finally user can seamlessly uses ORM as Xata SDK, it’s like reflection, a mirror, I mean basically we rewrite the code as plug-in.

Those request are sent through “SQL PROXY” that enabling parser instance to run pg-query-go library from PGAnalyze. These action require a maximum safety inspection. We’re keep on the track!

Examples and SDK Suppport

const { records: myRecord } = await xata.sql<TeamsRecord>`SELECT * FROM "teams"`;
const { records: myRecord } = await xata.sql<TeamsRecord>`SELECT * FROM "teams" WHERE name=${name}`;
const { records: myRecord } = await xata.sql<TeamsRecord>`SELECT "primaryTitle", md5("primaryTitle"), avg("runtimeMinutes") FROM titles GROUP BY "primaryTitle"`;
records = xata.sql().query('''SELECT * FROM "teams"''')
records = xata.sql().query('''SELECT * FROM "teams" WHERE name=$1''', params=[name])
records = xata.sql().query('''SELECT "primaryTitle", md5("primaryTitle"), avg("runtimeMinutes") FROM titles GROUP BY "primaryTitle"''')
// POST https://{workspace}.{region}.xata.sh/db/{db}:{branch}/sql
{
"statement": "SELECT * FROM \"teams\""
}
// POST https://{workspace}.{region}.xata.sh/db/{db}:{branch}/sql
{
"statement": "SELECT * FROM \"teams\" WHERE name=$",
"params": ["name"]
}
// POST https://{workspace}.{region}.xata.sh/db/{db}:{branch}/sql
{
"statement": "SELECT \"primaryTitle\", md5(\"primaryTitle\"), avg(\"runtimeMinutes\") FROM titles GROUP BY \"primaryTitle\""
}

Which better Kysely or Drizzle?

Comparing Kysely, and Drizzle Github Repositories.

  • 🍭 Kysely has less code (plug-in-kysely).
  • 🍭 Drizzle has more code, ❌ schema generator are unavailable.
Shoutout to SferaDev

Just for now, I think Kysely has better implementation than Drizzle, remember it’s just a tools. We’re going to continue deliver better services.

— Does Xata support synchronizer? over xata cli?

Everytime table changes, we must’ve re-prompt “xata codegen” to generate correct schema onto xata.rs, maybe in future we can cut this boundaries.

Xata playground are just getting better! 🦋

Introducing Xata SQL Playground and Snippet.

Xata > Sign In > Dashboard > Playground

Xata now support SQL command through Xata Playground — PostgresSQL, thus snippet saver, don’t waste your time to re-snippet your syntax. Xata adding small changes over time. Increasing the meaningfulness.

“Simplifying the app development and deployment”

— I’m Yusril Ihsanul Alim, Goodbye! 🦋