# Plucto

Plucto is a light weight unobtrusive pagination helper for elixir/phoenix(plug) web applications.
Plucto is a simple library for asbtracting common pagination functionality.
Plucto is intended to work with Plug and Ecto. It requires a conn struct, ecto query, and an ecto repo.

You might be familiar with query calls such as this:
  %User{} |> Repo.all()

To write this using Plucto you would do:
  from(u in User) |> Plucto.flip(conn, Repo)

Plucto is currently a configuration free library. It gets all the informaion it needs using the `Plug.Conn` struct.
The only two query parameters that matter are `page` and `limit`. Neither are required to initiate a paginated response. Plucto will default to page 1 and a limit of 25.

Consider a page that list users. is paginatable due to the Plucto defaults. is the same as this

To change pages or set limits change the query string parameters.

Plucto currently relies an a database column `id` for the count aggregate. Totals will not execute with column name other than id.
ie. `Repo.aggregate(query, :count, :id)`

The `flip/3` function will return a `%Plucto.Page{}` struct.

defmodule Plucto.Page do
  defstruct params: %{},
            repo: nil,
            query: nil,
            path_info: [],
            total: nil,
            limit: 25,
            offset: nil,
            current_page: nil,
            last_page: nil,
            from: nil,
            to: nil,
            data: []

## Installation

If [available in Hex](, the package can be installed
by adding `Plucto` to your list of dependencies in `mix.exs`:

def deps do
    {:plucto, "~> 0.1.0"}

Documentation can be generated with [ExDoc](
and published on [HexDocs]( Once published, the docs can
be found at [](