Home

Awesome

ExSieve

CI Hex Version Coverage Status Hex docs

ExSieve is a filtering solution for Phoenix/Ecto. It builds Ecto.Query structs from a ransack inspired query language.

Installation

Add ex_sieve to your list of dependencies in mix.exs:

def deps do
  [
    {:ex_sieve, "~> 0.8.2"},
  ]
end

Nice to have

Ecto internals currently used

Usage

Setup your application repo, using ExSieve

defmodule MyApp.Repo do
  use Ecto.Repo,
    otp_app: :my_app,
    adapter: Ecto.Adapters.Postgres

  use ExSieve
end

and use the provided c:ExSieve.filter/3 callback for filtering entries based on query parameters

def index(conn, %{"q"=> params}) do
  posts = MyApp.Repo.filter(MyApp.Post, params)

  render conn, :index, posts: posts
end

Examples

For more details on the used query language and query examples see the official documentation.

Contributing

First, you'll need to build the test database.

DB_PASSWORD=<db_password> MIX_ENV=test mix ecto.reset

This task assumes you have postgres installed and that your current user can create / drop databases. If you'd prefer to use a different user, you can specify it with the environment variable DB_USER.

When the database is built, you can run the tests.

mix test

and

mix credo