### EctoCooler Resource.all Function Example Source: https://hexdocs.pm/ecto_cooler/readme Demonstrates the usage of the `all/1` function generated by EctoCooler for fetching lists of records. It shows examples with preloads, ordering, and filtering using the `where` option. ```Elixir iex> Posts.all() [%Post{id: 1}] ``` ```Elixir iex> Posts.all(preloads: [:address]) [%Post{id: 1, comment: %Comment{}}] ``` ```Elixir iex> Posts.all(order_by: [desc: :id]) [%Post{id: 2}, %Post{id: 1}] ``` ```Elixir iex> Posts.all(preloads: [:comment], order_by: [desc: :id])) [ %Post{ id: 2, comment: %Comment{} }, %Post{ id: 1, comment: %Comment{} } ] ``` ```Elixir iex> Posts.all(where: [category: "Testing"]) [ %Post{ id: 42, category: "Testing" }, %Post{ id: 99, category: "Testing" } ] ``` -------------------------------- ### EctoCooler.TestRepo start_link/1 Function Source: https://hexdocs.pm/ecto_cooler/readme Starts the Ecto repository process, typically used in application supervision trees. ```elixir EctoCooler.TestRepo.start_link(MyApp.Repo) ``` -------------------------------- ### EctoCooler.TestRepo: start_link/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Starts a supervised Ecto repository process. This is a common function for integrating Ecto repositories with OTP supervision trees. ```elixir @spec EctoCooler.TestRepo.start_link(any()) :: any() ``` -------------------------------- ### Install EctoCooler Dependency Source: https://hexdocs.pm/ecto_cooler/readme This snippet shows how to add EctoCooler to your project's dependencies in the `mix.exs` file. ```Elixir def deps do [ # Use the latest 2.x release {:ecto_cooler, "~> 2.0"} ] end ``` -------------------------------- ### EctoCooler: Use EctoCooler Macro Source: https://hexdocs.pm/ecto_cooler/EctoCooler Demonstrates how to use the EctoCooler macro to import the `EctoCooler.using_repo/2` function. This is a basic setup for utilizing EctoCooler's capabilities. ```elixir use EctoCooler ``` -------------------------------- ### EctoCooler Posts.create Function Example Source: https://hexdocs.pm/ecto_cooler/readme Demonstrates the `create/1` function generated by EctoCooler for inserting a new Post record into the data store, returning an `:ok`/`:error` tuple. ```Elixir iex> Posts.create(%{title: "Example Post"}) {:ok, %Post{id: 123, title: "Example Post"}} ``` ```Elixir iex> Posts.create(%{invalid: "invalid"}) {:error, %Ecto.Changeset} ``` -------------------------------- ### EctoCooler.TestRepo child_spec/1 Function Source: https://hexdocs.pm/ecto_cooler/readme Generates a child specification for starting the repository as a supervised process. ```elixir EctoCooler.TestRepo.child_spec(MyApp.Repo) ``` -------------------------------- ### EctoCooler Posts.get! Function Example Source: https://hexdocs.pm/ecto_cooler/readme Shows the `get!/2` function generated by EctoCooler for fetching a single Post record by its primary key, which raises `Ecto.NoResultsError` if not found. ```Elixir iex> Posts.get!(1) %Post{id: 1} ``` ```Elixir iex> Posts.get!(999) ** (Ecto.NoResultsError) ``` ```Elixir iex> Posts.get!(1, preloads: [:comments]) %Post{ id: 1, comments: [%Comment{}], ... } ``` -------------------------------- ### EctoCooler Posts.get Function Example Source: https://hexdocs.pm/ecto_cooler/readme Illustrates the `get/2` function generated by EctoCooler for fetching a single Post record by its primary key, returning the record or `nil`. ```Elixir iex> Posts.get(1) %Post{id: 1} ``` ```Elixir iex> Posts.get(999) nil ``` ```Elixir iex> Posts.get(1, preloads: [:address]) %Post{ id: 1, address: %Address{} } ``` -------------------------------- ### EctoCooler Posts.change Function Example Source: https://hexdocs.pm/ecto_cooler/readme Shows how to use the `change/1` function generated by EctoCooler to create a changeset for a new or existing Post record. ```Elixir iex> Posts.change(%{title: "Example Post"}) #Ecto.Changeset< action: nil, changes: %{title: "Example Post"}, errors: [], data: #Post<>, valid?: true > ``` -------------------------------- ### EctoCooler Posts.create! Function Example Source: https://hexdocs.pm/ecto_cooler/readme Illustrates the `create!/1` function generated by EctoCooler for inserting a new Post record, which raises `Ecto.InvalidChangesetError` on failure. ```Elixir iex> Posts.create!(%{title: "Example Post"}) %Post{id: 123, title: "Example Post"} ``` ```Elixir iex> Posts.create!(%{invalid: "invalid"}) ** (Ecto.InvalidChangesetError) ``` -------------------------------- ### EctoCooler Posts.get_by Function Example Source: https://hexdocs.pm/ecto_cooler/readme Demonstrates the `get_by/1` function generated by EctoCooler for fetching a single Post record based on specified attributes, returning the record or `nil`. ```Elixir iex> Posts.get_by(%{title: "Example Title"}) %Post{title: "Example Title"} ``` ```Elixir iex> Posts.get_by(%{title: "Doesn't Exist"}) nil ``` -------------------------------- ### EctoCooler Posts.get_by! Function Example Source: https://hexdocs.pm/ecto_cooler/readme Illustrates the `get_by!/1` function generated by EctoCooler for fetching a single Post record by attributes, which raises `Ecto.NoResultsError` if not found. ```Elixir iex> Posts.get_by!(%{title: "Example Title"}) %Post{title: "Example Title"} ``` ```Elixir iex> Posts.get_by!(%{title: "Doesn't Exist"}) ** (Ecto.NoResultsError) ``` -------------------------------- ### EctoCooler.TestRepo get!/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Retrieves a single record, raising an error if not found. ```elixir EctoCooler.TestRepo.get!(MyApp.Repo, MyApp.User, 1) ``` -------------------------------- ### EctoCooler.TestRepo: get!/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Retrieves a single record, raising an error if no record matches the query. ```elixir @spec EctoCooler.TestRepo.get!(any(), any(), any()) :: any() ``` -------------------------------- ### Generate Ecto Repository with EctoCooler Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.Ectc.Gen This mix task generates an Ecto repository file using EctoCooler. It streamlines the setup of data access layers in Elixir applications. ```mix mix ectc.gen.repo ``` -------------------------------- ### EctoCooler Posts.delete Function Example Source: https://hexdocs.pm/ecto_cooler/readme Shows the `delete/1` function generated by EctoCooler for removing a Post record, returning an `:ok`/`:error` tuple. ```Elixir iex> Posts.delete(%Post{id: 1}) {:ok, %Post{id: 1}} ``` ```Elixir iex> Posts.delete(%Post{id: 999}) {:error, %Ecto.Changeset} ``` -------------------------------- ### EctoCooler Posts.delete! Function Example Source: https://hexdocs.pm/ecto_cooler/readme Demonstrates the `delete!/1` function generated by EctoCooler for removing a Post record, which raises `Ecto.StaleEntryError` on failure. ```Elixir iex> Posts.delete!(%Post{id: 1}) %Post{id: 1} ``` ```Elixir iex> Posts.delete!(%Post{id: 999}) ** (Ecto.StaleEntryError) ``` -------------------------------- ### EctoCooler.Templates.Migration: options/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Provides options for generating migrations. ```elixir @spec EctoCooler.Templates.Migration.options(any()) :: any() ``` -------------------------------- ### Full EctoCooler Configuration Source: https://hexdocs.pm/ecto_cooler/readme This snippet shows the complete configuration options for EctoCooler, including generator settings, migration directory, repo details, and schema details. ```Elixir config :ecto_cooler, app_name: "MyApp", app_slug: :my_app, generators: [binary_id: true], migration_dir: "priv/repo/migrations", repo_dir: "lib/my_app/repo", repo_namespace: "Repo", schema_dir: "lib/my_app/schema", schema_namespace: "Schema" ``` -------------------------------- ### EctoCooler Core Functions Source: https://hexdocs.pm/ecto_cooler/EctoCooler.Templates Core functions for EctoCooler, including a `__using__/1` macro for module integration, `resource/2` for defining resources, and `using_repo/2` for specifying the repository. ```Elixir __using__/1 resource/2 using_repo/2 ``` -------------------------------- ### EctoCooler: Run Resources Source: https://hexdocs.pm/ecto_cooler/EctoCooler Command to run EctoCooler resources, likely for generating or managing Ecto-related components. ```bash mix ecto_cooler.resources run/1 ``` -------------------------------- ### EctoCooler using_repo/2 Function Source: https://hexdocs.pm/ecto_cooler/readme The `using_repo/2` function is likely a helper to configure or use a specific Ecto repository within the context of EctoCooler's resource definitions. ```elixir defmodule MyApp.Accounts do alias MyApp.Accounts.User EctoCooler.using_repo(MyApp.Repo, User) end ``` -------------------------------- ### EctoCooler.TestRepo: checkout/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Checks out a database connection for the current process. ```elixir @spec EctoCooler.TestRepo.checkout(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: explain/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Provides an explanation of an Ecto query, often used for performance analysis. ```elixir @spec EctoCooler.TestRepo.explain(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo prepare_query/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Prepares an Ecto query with specific options before execution. ```elixir EctoCooler.TestRepo.prepare_query(MyApp.Repo, MyApp.User, query) ``` -------------------------------- ### EctoCooler.TestRepo: prepare_query/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Prepares an Ecto query for execution, potentially optimizing it. ```elixir @spec EctoCooler.TestRepo.prepare_query(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler Resource Generation Source: https://hexdocs.pm/ecto_cooler/EctoCooler.Templates Function to run the resource generation process for EctoCooler, which includes generating associated files and configurations. ```Elixir run(options) ``` -------------------------------- ### Generate Repo, Schema, and Migration Files Source: https://hexdocs.pm/ecto_cooler/readme Generates an Ecto Repo module, a Schema module, and a Migration file. The command takes the repository name, schema name, table name, and attributes as arguments. ```Shell mix ectc.gen.repo Posts Post posts title:string author:string ``` -------------------------------- ### Configure EctoCooler for Generators Source: https://hexdocs.pm/ecto_cooler/readme This snippet demonstrates the minimal application configuration required for EctoCooler generators, including `app_name` and `app_slug`. ```Elixir config :ecto_cooler, app_name: "MyApp", app_slug: :my_app ``` -------------------------------- ### EctoCooler.TestRepo explain/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Explains the SQL query generated for the given Ecto schema and query. ```elixir EctoCooler.TestRepo.explain(MyApp.Repo, MyApp.User, query) ``` -------------------------------- ### EctoCooler.using_repo/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Specifies the Ecto repository to be used by the generated resources. ```elixir @spec EctoCooler.using_repo(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo checkout/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Checks out a connection from the repository pool, potentially with specific options. ```elixir EctoCooler.TestRepo.checkout(MyApp.Repo, timeout: 5000) ``` -------------------------------- ### EctoCooler.TestRepo: prepare_transaction/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Prepares a transaction for execution. ```elixir @spec EctoCooler.TestRepo.prepare_transaction(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: config/0 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Retrieves the configuration for the repository. ```elixir @spec EctoCooler.TestRepo.config() :: any() ``` -------------------------------- ### EctoCooler: Generate Repo Source: https://hexdocs.pm/ecto_cooler/EctoCooler Command to generate a new Ecto repository file using the ectc mix task provided by EctoCooler. ```bash mix ectc.gen.repo ``` -------------------------------- ### EctoCooler Repository Template Generation Source: https://hexdocs.pm/ecto_cooler/EctoCooler.Templates Functions for generating Ecto repository contexts, including creating a new context and generating its files. ```Elixir create_context(name) generate(assigns) ``` -------------------------------- ### EctoCooler.Templates.Repo create_context/1 Function Source: https://hexdocs.pm/ecto_cooler/readme This function is used for generating Ecto repository-related files, specifically creating a new context module. ```elixir EctoCooler.Templates.Repo.create_context("Accounts") ``` -------------------------------- ### EctoCooler.TestRepo load/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Loads associated data for a given schema and query. ```elixir EctoCooler.TestRepo.load(MyApp.Repo, MyApp.User) ``` -------------------------------- ### EctoCooler Mix Tasks Source: https://hexdocs.pm/ecto_cooler/EctoCooler.Templates Mix tasks provided by EctoCooler for generating migrations, repositories, and schemas. Also includes a task for managing Ecto resources. ```Shell mix ectc.gen.migration mix ectc.gen.repo mix ectc.gen.schema mix ecto_cooler.resources ``` -------------------------------- ### EctoCooler Migration Template Generation Source: https://hexdocs.pm/ecto_cooler/EctoCooler.Templates Functions for generating Ecto migration files, including creating a new migration and defining its fields and options. ```Elixir create_migration(name) fields(fields) generate(assigns) options(options) ``` -------------------------------- ### Mix Task: ecto_cooler.resources Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler This mix task lists resources defined by EctoCooler within a context module. It helps in understanding the generated resource functions for Ecto contexts, such as functions for retrieving, creating, updating, and deleting data. ```bash $ mix ecto_cooler.resources MyApp.MyContext ``` ```elixir iex> ``` -------------------------------- ### EctoCooler.Templates.Repo: generate/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Generates the Ecto repository code. ```elixir @spec EctoCooler.Templates.Repo.generate(any()) :: any() ``` -------------------------------- ### EctoCooler: Define Schema Access with Repo Source: https://hexdocs.pm/ecto_cooler/EctoCooler Illustrates how to define schema access within a given Ecto.Repo using the `using_repo/2` macro. This is typically used in conjunction with the `resource/2` macro to manage schema operations. ```elixir using_repo(Repo) do resource(Schema) end ``` -------------------------------- ### EctoCooler.TestRepo default_options/1 Function Source: https://hexdocs.pm/ecto_cooler/readme Returns the default options used for operations with the specified repository. ```elixir EctoCooler.TestRepo.default_options(MyApp.Repo) ``` -------------------------------- ### EctoCooler.TestRepo get_dynamic_repo/0 Function Source: https://hexdocs.pm/ecto_cooler/readme Retrieves the currently configured dynamic Ecto repository. ```elixir EctoCooler.TestRepo.get_dynamic_repo() ``` -------------------------------- ### EctoCooler: Define Resource Functions with Repo Source: https://hexdocs.pm/ecto_cooler/EctoCooler Shows how to define CRUD methods for a given Ecto.Repo within a module using the `resource/2` macro. It illustrates generating all functions, with suffixes, specific functions, excluding functions, and generating read, write, or delete operations. ```elixir using(Repo) do resource(Schema) end ``` ```elixir using(Repo) do resource(Schema, suffix: true) end ``` ```elixir using(Repo) do resource(Schema, only: [:get]) end ``` ```elixir using(Repo) do resource(Schema, except: [:delete]) end ``` ```elixir using(Repo) do resource(Schema, :read) end ``` ```elixir using(Repo) do resource(Schema, :write) end ``` ```elixir using(Repo) do resource(Schema, :delete) end ``` -------------------------------- ### EctoCooler.Templates.Migration create_migration/1 Function Source: https://hexdocs.pm/ecto_cooler/readme This function is part of the migration template generation. `create_migration/1` likely takes a name for the migration file. ```elixir EctoCooler.Templates.Migration.create_migration("create_users") ``` -------------------------------- ### EctoCooler.TestRepo insert/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Inserts a new record into the repository. ```elixir EctoCooler.TestRepo.insert(MyApp.Repo, %MyApp.User{name: "John Doe"}) ``` -------------------------------- ### EctoCooler.TestRepo insert_all/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Inserts multiple records into the repository efficiently. ```elixir EctoCooler.TestRepo.insert_all(MyApp.Repo, MyApp.User, [%{name: "Alice"}, %{name: "Bob"}]) ``` -------------------------------- ### EctoCooler: Generate Migration Source: https://hexdocs.pm/ecto_cooler/EctoCooler Command to generate a new Ecto migration file using the ectc mix task provided by EctoCooler. ```bash mix ectc.gen.migration ``` -------------------------------- ### EctoCooler.TestRepo: get_dynamic_repo/0 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Retrieves the currently set dynamic repository. ```elixir @spec EctoCooler.TestRepo.get_dynamic_repo() :: any() ``` -------------------------------- ### EctoCooler.Templates.Migration options/1 Function Source: https://hexdocs.pm/ecto_cooler/readme This function likely processes or returns options related to migration generation, possibly for customizing the generated migration file. ```elixir EctoCooler.Templates.Migration.options(MyApp.User) ``` -------------------------------- ### EctoCooler.TestRepo: insert_all/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Inserts multiple records into the repository at once. ```elixir @spec EctoCooler.TestRepo.insert_all(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo query/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Executes a raw Ecto query against the repository. ```elixir EctoCooler.TestRepo.query(MyApp.Repo, "SELECT * FROM users", []) ``` -------------------------------- ### EctoCooler.Templates.Repo: create_context/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Generates a new Ecto repository context file. This function is part of the EctoCooler templating system for repositories. ```elixir @spec EctoCooler.Templates.Repo.create_context(String.t()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo put_dynamic_repo/1 Function Source: https://hexdocs.pm/ecto_cooler/readme Sets the dynamic Ecto repository for the current process. ```elixir EctoCooler.TestRepo.put_dynamic_repo(MyApp.Repo) ``` -------------------------------- ### EctoCooler.TestRepo prepare_transaction/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Prepares a transaction block for executing multiple Ecto operations atomically. ```elixir EctoCooler.TestRepo.prepare_transaction(MyApp.Repo, fn repo -> ... end) ``` -------------------------------- ### EctoCooler.TestRepo config/0 Function Source: https://hexdocs.pm/ecto_cooler/readme Retrieves the configuration for the specified Ecto repository. ```elixir EctoCooler.TestRepo.config() ``` -------------------------------- ### EctoCooler TestRepo Functions Source: https://hexdocs.pm/ecto_cooler/EctoCooler.Templates A collection of functions for interacting with a test repository, including CRUD operations, transactions, and query execution. ```Elixir aggregate/3 aggregate/4 all/2 all_by/3 checked_out?/0 checkout/2 child_spec/1 config/0 default_options/1 delete/2 delete!/2 delete_all/2 disconnect_all/2 exists?/2 explain/3 get/3 get!/3 get_by/3 get_by!/3 get_dynamic_repo/0 in_transaction?/0 insert/2 insert!/2 insert_all/3 insert_or_update/2 insert_or_update!/2 load/2 one/2 one!/2 preload/3 prepare_query/3 prepare_transaction/2 put_dynamic_repo/1 query/3 query!/3 query_many/3 query_many!/3 reload/2 reload!/2 rollback/1 start_link/1 stop/1 stream/2 to_sql/2 transact/2 transaction/2 update/2 update!/2 update_all/3 ``` -------------------------------- ### EctoCooler.TestRepo query_many/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Executes multiple raw Ecto queries. ```elixir EctoCooler.TestRepo.query_many(MyApp.Repo, ["SELECT * FROM users", "SELECT * FROM posts"], []) ``` -------------------------------- ### EctoCooler __using__/1 Macro Source: https://hexdocs.pm/ecto_cooler/readme The `__using__/1` macro is a common Elixir pattern used to inject functionality or define module attributes when a module uses this one. It's likely used here to set up EctoCooler's features within a module. ```elixir use EctoCooler # or with options use EctoCooler, repo: MyApp.Repo ``` -------------------------------- ### EctoCooler.TestRepo: load/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Loads data into a record, typically from a map or struct. ```elixir @spec EctoCooler.TestRepo.load(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: default_options/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Retrieves the default options for a repository operation. ```elixir @spec EctoCooler.TestRepo.default_options(any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: preload/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Preloads associated data for a list of records. ```elixir @spec EctoCooler.TestRepo.preload(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler.Templates.Migration: generate/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Generates the Ecto migration code. ```elixir @spec EctoCooler.Templates.Migration.generate(any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo preload/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Preloads associated data for a given schema and list of records. ```elixir EctoCooler.TestRepo.preload(MyApp.Repo, users, :posts) ``` -------------------------------- ### EctoCooler.TestRepo: all/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Retrieves all records matching the given query from the repository. ```elixir @spec EctoCooler.TestRepo.all(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo query_many!/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Executes multiple raw Ecto queries, raising an error if any fail. ```elixir EctoCooler.TestRepo.query_many!(MyApp.Repo, ["SELECT * FROM users", "SELECT * FROM posts"], []) ``` -------------------------------- ### EctoCooler Schema Generation Source: https://hexdocs.pm/ecto_cooler/EctoCooler.Templates Functions for generating Ecto schemas, including creating a schema from a list of attributes, defining fields, and validating attributes. ```Elixir create_schema(list) fields(attributes) generate(assigns) validated_attributes(attributes) ``` -------------------------------- ### EctoCooler.TestRepo query!/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Executes a raw Ecto query, raising an error if it fails. ```elixir EctoCooler.TestRepo.query!(MyApp.Repo, "SELECT * FROM users", []) ``` -------------------------------- ### EctoCooler.TestRepo stream/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Streams results from a query, useful for large datasets. ```elixir EctoCooler.TestRepo.stream(MyApp.Repo, MyApp.User) ``` -------------------------------- ### EctoCooler: Generate Schema Source: https://hexdocs.pm/ecto_cooler/EctoCooler Command to generate a new Ecto schema file using the ectc mix task provided by EctoCooler. ```bash mix ectc.gen.schema ``` -------------------------------- ### EctoCooler.TestRepo: query/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Executes a raw Ecto query against the repository. This allows for more complex or custom queries. ```elixir @spec EctoCooler.TestRepo.query(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: put_dynamic_repo/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Sets the dynamic repository for subsequent operations. ```elixir @spec EctoCooler.TestRepo.put_dynamic_repo(any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: insert/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Inserts a new record into the repository. It takes the changes and the schema to be inserted. ```elixir @spec EctoCooler.TestRepo.insert(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.__using__/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Macro used to configure EctoCooler within a module, typically for defining resources. ```elixir @spec EctoCooler.__using__(any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: to_sql/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Converts an Ecto query into its SQL representation. ```elixir @spec EctoCooler.TestRepo.to_sql(any(), any()) :: any() ``` -------------------------------- ### EctoCooler Resource Generation Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.Ectc.Gen The `mix ecto_cooler.resources` task is used to generate resources within an Elixir project. This task simplifies the creation of common Ecto-related components. ```mix mix ecto_cooler.resources ``` -------------------------------- ### EctoCooler.TestRepo all/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Retrieves all records matching the given query from the specified repository. ```elixir EctoCooler.TestRepo.all(MyApp.Repo, MyApp.User) ``` -------------------------------- ### EctoCooler.Templates.Migration: create_migration/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Generates a new Ecto migration file. This function is part of the EctoCooler templating system for migrations. ```elixir @spec EctoCooler.Templates.Migration.create_migration(String.t()) :: any() ``` -------------------------------- ### EctoCooler.Templates.Migration: fields/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Generates migration fields based on provided definitions. ```elixir @spec EctoCooler.Templates.Migration.fields(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: query!/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Executes a raw Ecto query, raising an error if the query fails. ```elixir @spec EctoCooler.TestRepo.query!(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler.Templates.Schema create_schema/1 Function Source: https://hexdocs.pm/ecto_cooler/readme This function generates a new Ecto schema file, likely taking the schema name as an argument. ```elixir EctoCooler.Templates.Schema.create_schema("User") ``` -------------------------------- ### EctoCooler.TestRepo to_sql/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Converts an Ecto query into its SQL representation. ```elixir EctoCooler.TestRepo.to_sql(MyApp.Repo, MyApp.User) ``` -------------------------------- ### EctoCooler: Generate Resources Source: https://hexdocs.pm/ecto_cooler/readme This command generates resources, likely including CRUD functions and potentially other related modules, for a given Ecto schema. ```elixir mix ecto_cooler.resources # Example usage: mix ecto_cooler.resources --schema MyApp.User ``` -------------------------------- ### Generate All EctoCooler Functions Source: https://hexdocs.pm/ecto_cooler/readme This Elixir code demonstrates basic usage of EctoCooler to generate all default CRUD functions for a given Ecto Schema and Repo. ```Elixir defmodule MyApp.Repo.Posts do alias MyApp.Repo alias MyApp.Schema.Post use EctoCooler using_repo(Repo) do resource(Post) end end ``` -------------------------------- ### EctoCooler: Generate Repository Source: https://hexdocs.pm/ecto_cooler/readme This command generates a new Ecto repository file, which is essential for database interactions in Elixir applications. ```elixir mix ectc.gen.repo ``` -------------------------------- ### EctoCooler: Generate Migration Source: https://hexdocs.pm/ecto_cooler/readme This command generates a new Ecto migration file. It's a common task when setting up or modifying database schemas. ```elixir mix ectc.gen.migration ``` -------------------------------- ### EctoCooler.TestRepo get/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Retrieves a single record from the repository based on the schema, query, and primary key. ```elixir EctoCooler.TestRepo.get(MyApp.Repo, MyApp.User, 1) ``` -------------------------------- ### EctoCooler.Env get/1 Function Source: https://hexdocs.pm/ecto_cooler/readme The `get/1` function in `EctoCooler.Env` is used to retrieve environment variables. It likely takes the variable name as an argument. ```elixir EctoCooler.Env.get("MY_VARIABLE") ``` -------------------------------- ### EctoCooler.Templates.Schema: generate/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Generates the Ecto schema code. ```elixir @spec EctoCooler.Templates.Schema.generate(any()) :: any() ``` -------------------------------- ### Generate Read Data Access Functions with EctoCooler Source: https://hexdocs.pm/ecto_cooler/readme This snippet demonstrates how to use EctoCooler's `:read` alias to generate functions solely for reading data from an Ecto schema. It assumes a `MyApp.Repo` and `MyApp.Schema.Post`. ```Elixir defmodule MyApp.Repo.Posts do alias MyApp.Repo alias MyApp.Schema.Post use EctoCooler using_repo(Repo) do resource(Post, :read) end end ``` -------------------------------- ### EctoCooler.TestRepo all_by/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Retrieves all records matching a specific condition (key-value pair) from the repository. ```elixir EctoCooler.TestRepo.all_by(MyApp.Repo, MyApp.User, %{status: :active}) ``` -------------------------------- ### EctoCooler.TestRepo: stream/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Streams results from a query, useful for large result sets. ```elixir @spec EctoCooler.TestRepo.stream(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: query_many/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Executes a query to retrieve multiple records. ```elixir @spec EctoCooler.TestRepo.query_many(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler.Templates.Migration generate/1 Function Source: https://hexdocs.pm/ecto_cooler/readme This function is responsible for generating the migration file content based on the provided schema and fields. ```elixir EctoCooler.Templates.Migration.generate(MyApp.User) ``` -------------------------------- ### EctoCooler: Generate Schema Source: https://hexdocs.pm/ecto_cooler/readme This command generates a new Ecto schema file, defining the structure of your data models and their mapping to database tables. ```elixir mix ectc.gen.schema ``` -------------------------------- ### EctoCooler.TestRepo: get/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Retrieves a single record from the repository based on the query and parameters. It returns the record if found, otherwise nil. ```elixir @spec EctoCooler.TestRepo.get(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo aggregate/4 Function Source: https://hexdocs.pm/ecto_cooler/readme An overloaded version of `aggregate/3`, possibly allowing for more specific aggregation options or parameters. ```elixir EctoCooler.TestRepo.aggregate(MyApp.Repo, query, :sum, :amount) ``` -------------------------------- ### EctoCooler.TestRepo: one!/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Retrieves a single record, raising an error if no record matches the query. ```elixir @spec EctoCooler.TestRepo.one!(any(), any()) :: any() ``` -------------------------------- ### EctoCooler resource/2 Function Source: https://hexdocs.pm/ecto_cooler/readme The `resource/2` function is likely used to define CRUD operations for a specific Ecto resource (schema). It probably takes the schema module and a keyword list of options. ```elixir defmodule MyApp.Accounts do alias MyApp.Accounts.User EctoCooler.resource(User, repo: MyApp.Repo) end ``` -------------------------------- ### EctoCooler.TestRepo: one/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Retrieves a single record, returning nil if no record matches the query. ```elixir @spec EctoCooler.TestRepo.one(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.Templates.Repo generate/1 Function Source: https://hexdocs.pm/ecto_cooler/readme This function is responsible for generating the content of an Ecto repository file. ```elixir EctoCooler.Templates.Repo.generate(MyApp.Repo) ``` -------------------------------- ### EctoCooler.TestRepo: get_by!/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Retrieves a single record by a field and value, raising an error if no record matches. ```elixir @spec EctoCooler.TestRepo.get_by!(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler.Templates.Schema: create_schema/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Generates a new Ecto schema file. This function is part of the EctoCooler templating system for schemas. ```elixir @spec EctoCooler.Templates.Schema.create_schema(String.t()) :: any() ``` -------------------------------- ### EctoCooler.Templates.Schema: fields/1 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Generates schema fields based on provided definitions. ```elixir @spec EctoCooler.Templates.Schema.fields(any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo one/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Retrieves a single record matching the query, returning nil if no record is found. ```elixir EctoCooler.TestRepo.one(MyApp.Repo, MyApp.User) ``` -------------------------------- ### Generate Read/Write Data Access Functions (excluding delete) with EctoCooler Source: https://hexdocs.pm/ecto_cooler/readme This snippet shows how to use EctoCooler's `:read_write` alias to generate functions for reading and manipulating data, excluding delete operations. It covers functions like `change`, `create`, `create!`, `update`, and `update!`, assuming a `MyApp.Repo` and `MyApp.Schema.Post`. ```Elixir defmodule MyApp.Repo.Posts do alias MyApp.Repo alias MyApp.Schema.Post use EctoCooler using_repo(Repo) do resource(Post, :read_write) end end ``` -------------------------------- ### EctoCooler.TestRepo: all_by/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Retrieves all records matching a specific field and value. ```elixir @spec EctoCooler.TestRepo.all_by(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: query_many!/3 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Executes a query to retrieve multiple records, raising an error if the query fails. ```elixir @spec EctoCooler.TestRepo.query_many!(any(), any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo insert!/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Inserts a new record, raising an error if the insertion fails. ```elixir EctoCooler.TestRepo.insert!(MyApp.Repo, %MyApp.User{name: "Jane Doe"}) ``` -------------------------------- ### EctoCooler.TestRepo one!/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Retrieves a single record, raising an error if no record is found. ```elixir EctoCooler.TestRepo.one!(MyApp.Repo, MyApp.User) ``` -------------------------------- ### EctoCooler.TestRepo: reload/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Reloads a record from the database. ```elixir @spec EctoCooler.TestRepo.reload(any(), any()) :: any() ``` -------------------------------- ### Generate Ecto Migration with EctoCooler Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.Ectc.Gen This mix task generates a new Ecto migration file using EctoCooler. It helps in managing database schema changes efficiently. ```mix mix ectc.gen.migration ``` -------------------------------- ### EctoCooler.Env get/2 Function Source: https://hexdocs.pm/ecto_cooler/readme The `get/2` function in `EctoCooler.Env` allows retrieving an environment variable with a default value if the variable is not set. ```elixir EctoCooler.Env.get("MY_VARIABLE", "default_value") ``` -------------------------------- ### EctoCooler.TestRepo reload/2 Function Source: https://hexdocs.pm/ecto_cooler/readme Reloads a schema struct from the repository. ```elixir EctoCooler.TestRepo.reload(MyApp.Repo, user_struct) ``` -------------------------------- ### EctoCooler.TestRepo update_all/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Updates multiple records matching a query with new changes. ```elixir EctoCooler.TestRepo.update_all(MyApp.Repo, MyApp.User, %{status: :inactive}, [where: [status: :active]]) ``` -------------------------------- ### EctoCooler.resource/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Defines a resource within an Ecto context module, generating CRUD functions. ```elixir @spec EctoCooler.resource(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: insert!/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Inserts a record, raising an error if the insertion fails. ```elixir @spec EctoCooler.TestRepo.insert!(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo: exists?/2 Source: https://hexdocs.pm/ecto_cooler/Mix.Tasks.EctoCooler Checks if any records exist that match the given query. ```elixir @spec EctoCooler.TestRepo.exists?(any(), any()) :: any() ``` -------------------------------- ### EctoCooler.TestRepo get_by/3 Function Source: https://hexdocs.pm/ecto_cooler/readme Retrieves a single record based on a specific condition (key-value pair). ```elixir EctoCooler.TestRepo.get_by(MyApp.Repo, MyApp.User, %{email: "test@example.com"}) ``` -------------------------------- ### Generate Specific Functions with EctoCooler Source: https://hexdocs.pm/ecto_cooler/readme This Elixir code demonstrates how to use the `only` option with EctoCooler to generate only a specified subset of CRUD functions for a resource. ```Elixir defmodule MyApp.Repo.Posts do alias MyApp.Repo alias MyApp.Schema.Post use EctoCooler using_repo(Repo) do resource(Post, only: [:create, :delete!]) end end ```