EctoCooler (ecto_cooler v2.0.0)

This module provides a DSL to easily generate the basic functions for a schema. This allows the context to focus on interesting, atypical implementations rather than the redundent, drifting CRUD functions.

Link to this section Summary

Functions

Macro to define CRUD methods for the given Ecto.Repo in the using module.

Macro to define schema access within a given Ecto.Repo

Link to this section Functions

Link to this macro

__using__(_)

(macro)

Macro to import EctoCooler.using_repo/2

examples

Examples

use EctoCooler
Link to this macro

resource(schema, options \\ [suffix: false])

(macro)

Macro to define CRUD methods for the given Ecto.Repo in the using module.

examples

Examples

### Generate a complete set of resource functions, suffix defaults to false
using(Repo) do
  resource(Schema)
end

### Generate a complete set of resource functions, with a _<resource_name> suffix (ie. Posts.get_post_by, Posts.get_post, etc.)
using(Repo) do
  resource(Schema, suffix: true)
end

### Generate only a given list of functions
using(Repo) do
  resource(Schema, only: [:get])
end

### Generate every function except those in the given list
using(Repo) do
  resource(Schema, except: [:delete])
end

### Generate all read operation functions
using(Repo) do
  resource(Schema, :read)
end

### Generate all write (includes read) operation functions
using(Repo) do
  resource(Schema, :write)
end

### Generate only delete functions
using(Repo) do
  resource(Schema, :delete)
end
Link to this macro

using_repo(repo, list)

(macro)

Macro to define schema access within a given Ecto.Repo

examples

Examples

using_repo(Repo) do
  resource(Schema)
end