Current section
Files
Jump to
Current section
Files
ecto_command
readme2.md
readme2.md
Here are some usage examples of the library:
```elixir
defmodule MyApp.CreateUser do
use Ecto.Command, repo: MyApp.Repo
command "create_user"
param :name, :string, required: true
param :email, :string, required: true
param :age, :integer, default: 18
param :password, :string, required: true
param :address do
param :street, :string, required: true
param :city, :string, required: true
param :state, :string, required: true
param :zip, :string, required: true
end
def execute(params) do
# validate and process the params as needed
# create the user and return the result
end
end
```
```elixir
defmodule MyApp.UpdateUser do
use Ecto.Command, repo: MyApp.Repo
command "update_user"
param :id, :integer, required: true
param :name, :string
param :email, :string
param :age, :integer
param :password, :string
param :address do
param :street, :string
param :city, :string
param :state, :string
param :zip, :string
end
def execute(params) do
# validate and process the params as needed
# update the user and return the result
end
end
```