8000 Allow passing Ecto query and preloads as list_... function args by vincentvanbush · Pull Request #45 · curiosum-dev/contexted · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Allow passing Ecto query and preloads as list_... function args #45

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

Open
wants to merge 28 commits into
base: main
Choose a base branch
from

Conversation

vincentvanbush
Copy link
@vincentvanbush vincentvan 10000 bush commented Feb 4, 2025

Closes #44.

In CRUD function generation, it will now allow calling generated list_... functions in the following ways:

  • list_items() - lists all resources unfiltered
  • list_items(query) - lists all resources filtered by the query
  • list_items(query, [:category, :manufacturer]) - lists all resources preloaded with the associations
  • list_items([:category, :manufacturer]) - lists all resources preloaded with the associations

Preloads can be given as an atom (:category) or a list of atoms ([:category, :manufacturer]) just as in Repo.preload/2.

The Ecto queryable argument must be either:

  • the schema of the resource, or
  • a query with from clause that targets the schema of the resource.

For example, list_items(Item) can be called just as well as list_items(from i in Item) - these are the most commonly occurring implementations of Ecto.Queryable that make most sense when used with a specific schema.

@vincentvanbush vincentvanbush force-pushed the feature/44-add_query_and_preload_arguments_to_generated_list_functions branch from 4c2b50a to 555b4c5 Compare February 4, 2025 16:29
@vincentvanbush vincentvanbush force-pushed the feature/44-add_query_and_preload_arguments_to_generated_list_functions branch from 555b4c5 to 7b00130 Compare February 4, 2025 16:46
@vincentvanbush vincentvanbush force-pushed the feature/44-add_query_and_preload_arguments_to_generated_list_functions branch from 87c371b to 50b5a67 Compare February 6, 2025 14:04
@vincentvanbush vincentvanbush force-pushed the feature/44-add_query_and_preload_arguments_to_generated_list_functions branch from 73ee7b7 to e1c4730 Compare February 10, 2025 11:27
@vincentvanbush vincentvanbush force-pushed the feature/44-add_query_and_preload_arguments_to_generated_list_functions branch from e1c4730 to dd56b7c Compare February 10, 2025 11:33
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.

Add query and preload arguments to generated list functions
1 participant
0