u/DanielFGray

393 post karma · 3,719 comment karma · joined Aug 2011 · moderator

DanielFGray

Take a picture of yourself, license it as public domain(!!), then (if I'm not mistaken) you can edit the article to use the new picture.

DanielFGray

Hey this looks pretty awesome

DanielFGray

glad it helped!

DanielFGray

Sure but not every database understands relations and how to maintain data integrity

DanielFGray

git submodules are a nightmare to remove, OP please don't do this

DanielFGray

you can roll your own using pipeWith

const pipeP = R.pipeWith((f, p) => p.then(f))
const effect = pipeP([x => Promise.resolve(x), R.toUpper, console.log])
effect('hello world')

but ideally you should use a library that properly handles async transforms, because this doesnt handle errors, timeouts, etc

DanielFGray

Row-level security is usually the answer to access control in Supabase

Here's an example I use on my blog for comments:

alter table comments enable row level security;

grant select on comments to anon;
grant
  select,
  insert (body, slug, parent_id),
  update (body)
  delete
on comments to authenticated;

create policy select_all_comments
  on comments for select
  using (true);
create policy insert_own_comment
  on comments for insert
  with check (user_id = auth.uid());
create policy update_own_comment
  on comments for update
  using (user_id = auth.uid());
create policy delete_own_comment
  on comments for delete
  using (user_id = auth.uid());

You may find my whole article on creating a comment system in Supabase helpful: https://danielfgray.com/articles/diy-comments

And the Postgres docs for RLS: https://www.postgresql.org/docs/current/ddl-rowsecurity.html

PostGraphile also a has a RLS cheat sheet: https://learn.graphile.org/docs/PostgreSQL_Row_Level_Security_Infosheet.pdf

DanielFGray

Personally I don't think nested ternaries are as big a deal as some folks seem to make them out to be.

To use a contrived example:

if (conditionA) {
  if (conditionB) {
    return valueA;
  }
  return valueB;
}
return valueC;

is, imo, much less readable than

! conditionA ? valueC
: conditionB ? valueA
: valueB
DanielFGray

Why would you manually fill relation fields instead of using a lateral join and json_agg, nested or not

I've yet to encounter anything an ORM can do that can't be done in SQL with better performance.

The fact that you need to drop into raw queries for performance reasons and more complex queries is the telltale sign it's a bad abstraction: it only works for the simplest cases.

Sure it's less typing for simple things, but I'd rather type a little more in those simple cases and use my existing knowledge than deal with looking up how to do simple things in whatever ORM du jour is popular.

DanielFGray

Neither, because ORMs are an anti-pattern

Edit: Downvotes aren't supposed to be for disagreement, but okay. The question was what would I pick and that's my answer.

DanielFGray

Not even close

DanielFGray

Worth pointing out there is a dedicated xml type

DanielFGray

I also like those UI components, I just like using Tailwind UI as a starting point and it's easy to edit them from there since they're just tailwind classes on regular HTML (or they have JSX examples as well)

DanielFGray

Tailwind UI is absolutely fantastic

It's fine if you can't justify buying it, but that doesn't mean it's not a quality product.

DanielFGray

I worked on left-leading one-foot blasts for a while and found that quite helpful.

DanielFGray

Why does one need to be protected from slightly complex SQL?

DanielFGray

So what have you tried so far?

DanielFGray

That's premature optimization.

You've created unidiomatic code for unperceivable [alleged] performance benefits.

DanielFGray

Try Supabase discord

DanielFGray

I wonder if this can be used server side, and eg reload express routes/middleware

DanielFGray

ORM users argue this [the DDL schema] imperative approach to schema modeling isn’t developer-friendly, as there’s is no written representation of your schema. This makes it difficult to conceptualize the current schema state.

Instead, ORMs provide a way to write your schema declaratively

I don't like ORMs either, but I don't agree ORMs are more declarative than SQL DDL

ORMs provide a limited set of CRUD functionality: simple queries, nested queries, the ability to filter by some limited set of operators, nested mutations, inserts, updates, and deletes. Advanced options may support upserts, basic aggregations, and grouping.

SQL, by contrast, is a full-fledged query language that supports a full library of functions and operators, computed properties, subqueries, window functions, advanced grouping and analytical queries, type conversion operations, set operations like union and distinct, common table expressions, recursive queries…the list goes on.

And that’s just the query language; SQL schemas are also richer and more sophisticated. They have a rich typesystem consisting of string, boolean, numeric, geometric, monetary, temporal, and geographical datatypes, plus computed properties, stored procedures, database views, triggers, and more.

Yeah this is the part I like about SQL honestly

EdgeDB has a robust type system that’s most comprehensive that most ORMs, but without the bloat that’s common among RDBMSs.

Ummm?

DanielFGray

Huge bundle size though 😬

DanielFGray

They're great when you need them

DanielFGray

You don't need permission to create projects, especially for educational purposes

DanielFGray

Looks like well structured data that would be better off stored in normalized tables rather than lumped into a text blob.