Skip to content
This repository has been archived by the owner on May 12, 2024. It is now read-only.

feat: Improve the ORM #1

Open
pythonbrad opened this issue Mar 4, 2022 · 0 comments
Open

feat: Improve the ORM #1

pythonbrad opened this issue Mar 4, 2022 · 0 comments
Labels
enhancement New feature or request

Comments

@pythonbrad
Copy link
Owner

pythonbrad commented Mar 4, 2022

Problem

The ORM don't permit to do some operations (will be describe below) directly in the database.
It's will be useful and better to be able to do it. Solve this problem, will also permit to replace the usage of special attributes who was a short-term solution.

Example

Count a set of objects

Before

count($question->answers);

Expected

$question->answers->count();

Verify if a set of objects exists

Before

if (count($question->answers)) {
   ...
}

Expected

if ($question->answers->exists()) {
  ...  
}

Delete a set of objects

Before

foreach ($question->answers as $answer) {
    $answer->delete();
}

Expected

$question->answers->delete();

Order a set of objects

Before

function score($quiz)
{
    return $quiz->score;
}
array_filter($user->quizzes, "score")

Expected

$user->quizzes->orderBy("score");
@pythonbrad pythonbrad added the enhancement New feature or request label Mar 4, 2022
@pythonbrad pythonbrad self-assigned this Mar 11, 2022
@pythonbrad pythonbrad removed their assignment Jan 5, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant