mix ecto.gen.queries (schema_generator v0.4.0)

Task for running a generator to write query functions. All query functions are designed to be composable, as in a query is required as the first argument. The task takes command line options to control generating functions to only what is necessary. If a function already exists with the same name as a generated function, it will be skipped. The exception for this is if a sort function is tagged as :sg_override, using the syntax @tag :sg_override. This function will be kept, with other sort functions generated as usual. Any of the overridden functions will be added after the generated sort functions.

Command line options

  • {files_or_directory} - which file or files to generate query functions for

  • --skip-fields - won't generate field based query functions, aka by_field(query, field)

  • --skip-assocs - won't generate assoc based query functions, aka with_assoc(query)

  • --skip-sort - won't generate field sorting query functions, aka sort(query, "field_asc")

  • --primary-key {string} - allows overriding the default primary key function generation when the pk isn't found in the file

  • --quiet - runs without logging

  • --ci - runs a validation for ci, if any files change it will generate an error

Summary

Functions

Link to this function

generate(path_or_files, options)

Link to this function

generate_query_functions(filename, options)

@spec generate_query_functions(binary(), map()) :: :error | :generated | :noop
Link to this function

sg_override_tag?(arg1)