View Source API Reference ecto_forge v0.1.4

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

This module creates an instance with functions from EctoForge.DatabaseApi

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 last with your EctoForge.CreateInstance

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

## When you coonnect You can use Api https://hexdocs.pm/ecto/Ecto.Query.html#last/2 ### Example

Use limit with your EctoForge.CreateInstance

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

## When you coonnect You can use Api https://hexdocs.pm/ecto/Ecto.Query.html#limit/3 ### Example

Use with your EctoForge.CreateInstance

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

## When you coonnect You can get only query with your find_all get_all find ### Example

Use with your EctoForge.CreateInstance

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

## When you coonnect You can use Api https://hexdocs.pm/ecto/Ecto.Query.html#order_by/3 ### 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