Giter VIP home page Giter VIP logo

ex_sieve's Introduction

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

  • Add advanced search documentation
  • Configure predicate aliases
  • Demo project

Ecto internals currently used

  • %Ecto.Query{from: %{source: {_, module}}} Ecto.query struct internal structure, needed for extracting the main Ecto.Schema of the query

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

ex_sieve's People

Contributors

albertored avatar dotsent avatar drnikon avatar juise avatar s33m4nn avatar valyukov avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.