View Source API Reference ecto_forge v0.1.2

Modules

EctoForge

Motiviation

This module allows on-the-go editing of contexts, extensions, and providing basic work for the database with ecto. With this module you can add your own extensions for functions such as find_all get_all get! find

!!!!! THIS MODULE IS DEVELOP,EXPEREMINTAL USING !!!!!!!!

This module allows you to catch Events using callback functions.

Using

Create your callbacks with EctoForge.CreateExtension.Events

defmodule Test.Event.ExtensionDeleteId do
use EctoForge.CreateExtension.Events

def after_get(result) do
  result |> Map.delete(:password)
end

def after_created({:ok, item}) do
  {:ok, item |> Map.delete(:password)}
end
end

Connect to your instansr or DataBaseApi

use EctoForge.CreateInstance,
  extensions_events: [MyApp.EctoForge.PasswordDeleter],
  repo: MyApp.Repo

You can use callback functions for processing. After the query and before the query to filter the data.

You can use callback functions for processing. After the query and before the query to filter the data. module MyApp.UserModel -> your own module mode -> :all or :one query -> handled query repo -> MyApp.Repo list_exetensions_executed -> Executed list of extensions attrs -> attributes that fall

Create your instanse EctoForge and use for your context or Models

Using

defmodule MyApp.EctoForgeInstanse do
 use EctoForge.CreateInstance,
  extensions_events: [Test.Event.ExtensionDeleteId],
  extensions_get: [
    EctoForge.Extension.Get.Preload,
    EctoForge.Extension.Get.Filter,
    EctoForge.Extension.Get.Pagination
  ],
  repo: EctoForge.Repo
end

Connect to your model

defmodule EctoForgeTest.UserModel do
use Ecto.Schema
import Ecto.Changeset

@type t() :: %__MODULE__{}

schema "user" do
  field(:name, :string)
  # timestamps()
end

use EctoForge.CreateInstance
@doc false

def changeset(emails_model \ %__MODULE__{}, attrs) do
  emails_model
  |> cast(attrs, [:name])
  |> validate_required([:name])
end
end

Connect to your context

defmodule MyApp.Context.UserModel do
use MyApp.EctoForgeInstanseBase, module_model: MyApp.UserModel
end

Implements base functions for database

use(
          EctoForge.DatabaseApi,
          [
            repo: MyApp.Repo, # required param
            extensions_get: [], # default list
            extensions_events: [] # default list
          ]
        )

functions find_all, works only with extension EctoForge.Extension.Get.Preload, EctoForge.Extension.Get.Filter or you can write yours own

Use aggregate with your model

When you using this module your functions find get_all returns 0

Implements library https://hexdocs.pm/filtery/readme.html

use EctoForge.CreateInstance,
extensions_get: [
  EctoForge.Extension.Get.Filter,
  ],
  repo: MyApp.Repo

## When you coonnect You can use Api https://hexdocs.pm/filtery/readme.html ### Example

Use preload with your model

Example

MyApp.UserModel.find(preload: [:posts])

Usage

use EctoForge.CreateInstance,
  extensions_get: [
    EctoForge.Extension.Get.Preload,
  ],
  repo: MyApp.Repo

The helper module is used to perform an extension for the find_all get_all get!() get! functions. You can use and create your binder