ExCrud

Installation

If available in Hex, the package can be installed by adding ex_crud to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_crud, "~> 0.1.3"}
  ]
end

Crud function injection


    defmodule MyApp.Post do
      use ExCrud, context: MyApp.Repo, schema_module: MyApp.Post.PostSchema
    end

- `add/1`

  ### Examples for `add/1`
  ```elixir
  - `iex> MyApp.Post.add(%{key1: value1, key2: value2})`
    `{:ok, struct}`
  - `iex> MyApp.Post.add(key1: value1, key2: value)`
    `{:ok, struct}`
  ```

- `get/1`

  ### Examples for `get/1`
  ```elixir  
    - `iex> MyApp.Post.get(1)`
      `{:ok, struct}`

    - `iex> MyApp.Post.get(id: 1)`
      `{:ok, struct}`

    - `iex> MyApp.Post.get(%{id: 1})`
      `{:ok, struct}`
  ```

- `get_all/0`

  ### Examples for `get_all/0`
  ```elixir
    - `iex> MyApp.Post.get_all()`
    `{:ok, list of structures}`
  ```

- `get_few/1`

  ### Examples for `get_few/1`
  ```elixir
    - `iex> MyApp.Post.get_few(200)`
      `{:ok, list of structures}`
  ```

- `update/2`

  ### Examples for `update/1`
  ```elixir
    - `iex> MyApp.Post.update(struct, key: value)`
      `{:ok, list of structures}`

    - `iex> MyApp.Post.update(struct, %{key: value})`
      `{:ok, list of structures}`

    - `iex> MyApp.Post.update(id, key: value)`
      `{:ok, list of structures}`

    - `iex> MyApp.Post.update(id, %{key: value})`
      `{:ok, list of structures}`
  ```

- `delete/1`

  ### Examples for `delete/1`
  ```elixir
    - `iex> MyApp.Post.delete(1)`
      `{:ok, structure}`

    - `iex> MyApp.Post.delete(struct)`
      `{:ok, structure}`
  ```