Skip to content

Conversation

@vincentvanbush
Copy link
Contributor

@vincentvanbush vincentvanbush 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

2 participants