Skip to content

Feat: add read Logic (Going for a function-based API instead of relying heavily on structs) - #23

Merged
VoidClancy merged 2 commits into
masterfrom
codegen-READ
Jul 8, 2026
Merged

Feat: add read Logic (Going for a function-based API instead of relying heavily on structs)#23
VoidClancy merged 2 commits into
masterfrom
codegen-READ

Conversation

@VoidClancy

@VoidClancy VoidClancy commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Going for a function-based API instead of relying heavily on structs

1- add conditional imports on the client header template

2-define a new model_predicate template that handles uniques and first level logical operators (and, or, not), and define fields of models on the generic field or the string helper to allow chaining other logical operators (EQ, NEQ, GT, LT...etc)

3- define builders_read, same generic modular design as the create ops, returns a builder with client, array of predicates and an exec function, define executeFindOne/FindMany() as helper to use them in executeSingle/ManyWithRelations() that does transaction in case of relations present

4- define sub-packages to house type aliases and make the api less verbose, for model fields, logical operators,select, create and omit,which is more natural and less verbose than having to import from the client.model each time

5- define FindFirst, many and unique funcs on the predicate, returning a builder with the exec function, that simply compiles predicates and builds raw SQL

6- Define generic query building blocks in the client package (StandardPredicate, Field[T], UniqueField[T], and specialized string fields) that implement the Predicate and UniquePredicate interfaces, expose logical operators (&, ||, !) as global functions to compose queries, and implement type-safe comparison operators (EQ, NEQ, GT, LT,...etc) as methods on the field structs,allowinh all generated models to reuse these building blocks, preventing duplicate, per-model query handlers

7- add read_test to the suite trying to cover edge cases as much as i can think of

2-define a new  model_predicate template that handles uniques and first level logical operators (and, or, not), and define fields of models on the generic field or the string helper to allow chaining other logical operators (EQ, NEQ, GT, LT...etc)

3- define builders_read, same generic modular design as the create ops, returns a builder with client, array of predicates and an exec function, define executeFindOne/FindMany() as helper to use them in executeSingle/ManyWithRelations() that does transaction in case of relations present

4- define sub-packages to house type aliases and make the api less verbose, for model fields, logical operators,select, create and omit,which is more natural and less verbose than having to import from the client.model each time

5- define FindFirst, many and unique funcs on the predicate, returning a builder with the exec function, that simply compiles predicates and builds raw SQL

6- Define generic query building blocks in the client package (StandardPredicate, Field[T], UniqueField[T], and specialized string fields) that implement the Predicate and UniquePredicate interfaces, expose logical operators (&, ||, !) as global functions to compose queries, and implement type-safe comparison operators (EQ, NEQ, GT, LT,...etc) as methods on the field structs,allowinh all generated models to reuse these building blocks, preventing duplicate, per-model query handlers

7- add read_test to the suite trying to cover edge cases as much as i can think of
@VoidClancy VoidClancy changed the title 1- conditional imports in the client header Feat: add read Logic Jul 8, 2026
@VoidClancy VoidClancy changed the title Feat: add read Logic Feat: add read Logic (Going for a function-based API instead of relying heavily on structs) Jul 8, 2026
… of doing it inline

1- add validate function to the predicate interface

2- implement a detached validateValue() helper that checks for valid UTF-8 strings and null bytes, used by PredicateData's validate and called via StandardPredicate to support validation on queries nested inside logical operators, validate read queries in FindFirst/Many, and FindUnique(the where clause validation for required)
@VoidClancy
VoidClancy merged commit dd97391 into master Jul 8, 2026
3 checks passed
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.

1 participant