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

Allow for resolving related models #152

Merged
merged 4 commits into from
Feb 23, 2025
Merged

Allow for resolving related models #152

merged 4 commits into from
Feb 23, 2025

Conversation

leo
Copy link
Member

@leo leo commented Feb 23, 2025

At the moment, it is already possible to address all models at once with a single query:

get.all();
count.all();

// etc.

Those queries are helpful because they avoid needing to first resolve the list of models before being able to compose queries for the resolved models. SQLite does not provide a solution for dynamically composing queries like that either, so we integrated it into the compiler instead.

The current change applies one more improvement to those queries, by allowing for only selecting the linked models of a specific model, which would otherwise not be possible:

get.all.for('member');

Assuming that the "member" model, for example, has two link fields pointing to the models "account" and "team", then the get.all query above would only resolve the records of those two models.

The syntax is not final. The objective at the moment is to unblock our own use cases and then iterate on it further. This is also the last change of this nature that is needed (I want to keep them to a minimum).

@leo leo added the enhancement New feature or request label Feb 23, 2025
Copy link

github-actions bot commented Feb 23, 2025

Released an experimental package:

bun add @ronin/compiler@leo-ron-1099-experimental-394

This package will be removed after the pull request has been merged.

Copy link

codecov bot commented Feb 23, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Files with missing lines Coverage Δ
src/index.ts 100.00% <100.00%> (ø)
src/model/index.ts 100.00% <100.00%> (ø)

@leo leo marked this pull request as ready for review February 23, 2025 10:05
@leo leo enabled auto-merge (squash) February 23, 2025 10:05
@leo leo merged commit 9f32095 into main Feb 23, 2025
4 checks passed
@leo leo deleted the leo/ron-1099 branch February 23, 2025 10:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants