Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify the builder structure #7

Merged
merged 3 commits into from
Dec 30, 2024
Merged

Conversation

zoedsoupe
Copy link
Collaborator

@zoedsoupe zoedsoupe commented Dec 29, 2024

Problem

postgres-js and other implementations that relies on OOP languages separate operations in a logical way, being delimited by the called "builders", which remains 3:

  • QueryBuilder: select, insert, update, ...
  • FilterBuilder: match, eq, neq, range, ...
  • TransformBuilder: limit, single, ...

That makes sense when you can chain method to a single structure, however in elixir data is immutable and state is explicit, so we do not have methods that can mutate state but instead function that modify the state (given as param) and return a new copy of this state, changed.

I could split the main module Supabase.PostgREST

Solution

Split the Supabase.PostgREST into:

  • Supabase.PostgREST.FilterBuilder
  • Supabase.PostgREST.QueryBuilder
  • Supabase.PostgREST.TransformBuilder

The Supabase.PostgREST function nows delegates all functions to these submodules, so we don't break the main API

Rationale

Closes #5

@zoedsoupe zoedsoupe merged commit 646fab7 into main Dec 30, 2024
1 check passed
@zoedsoupe zoedsoupe deleted the refactor/simplify-builder branch December 30, 2024 00:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove distinction between QueryBuilder and FilterBuilder
1 participant