aditya7iyengar

aditya7iyengar

Rummage.Ecto - Searching, Sorting and Pagination in Ecto & Phoenix

Rummage.Ecto and Rummage.Phoenix provide ways to perform Searching, Sorting and Pagination over Ecto queries and Phoenix collections.

For more details visit this blog

Here’s a little demo:

Most Liked

brightball

brightball

michalmuskala

michalmuskala

This looks like a great project - it has several issues, though (I’m speaking only about the ecto part - haven’t looked at others yet).

It injects a lot of code and functions inside __using__/1 - it is considered a bad practice. This leads to multiple issues - including slower compilation and inferior debugging experience.
It also couples schema to the repo module, which is something ecto actively avoids.

As an alternative, I could easily imagine a pure function-based interface, for example:

Rummage.Ecto.paginate(query, MyApp.Repo)
# instead of
MySchema.rummage(query)

The schema can be easily extracted from the query:

query = Ecto.Queryable.to_query(query)
{_source, schema} = query.from

One thing to note, though is that the schema can be nil, since it’s not required, but I also don’t see really a reason why it would be needed.

aditya7iyengar

aditya7iyengar

That’s a great suggestion! It will be great to not have a lot of code in __using__/1. I guess I have some work to do over this week. Thanks for your input!

aditya7iyengar

aditya7iyengar

Hi everyone!

I wrote a library which provides ways to perform Searching, Sorting and Pagination over Ecto queries and Phoenix collections: Rummage. Rummage has been split into two libraries: Rummage.Ecto and Rummage.Phoenix.

Rummage is a Ransack-like library, which is designed in the Elixir way. Which means no defining functions on the models, transparency and configurability!

Rummage comes with a lot of powerful features which are available right away, without writing a bunch of code. Here are a few blogs that talk about how to use Rummage in a Phoenix or an Ecto application:

Let me know if you have any thoughts on Rummage!

Thank you!

Here’s a little demo:
Rummage

aditya7iyengar

aditya7iyengar

Very interesting! I agree with the implementation problems with offset, however I question the cost of adding it to Rummage.Ecto vs the benefits it will provide. However, it would be fun to implement a custom hook for that. This is precisely why I made Rummage.Ecto configurable, which means you can write a simple pagination hook to do what you’re saying, while using its Search and Sort hooks with all the HTML support.

Where Next?

Popular in Libraries Top

mhanberg
I just released the first version of Temple: an HTML DSL for Elixir and Phoenix! You can read this blog post or the docs for more info...
New
Qqwy
While not as prevalent as in imperative languages, arrays (collections with efficient random element access) are still very useful in Eli...
New
mplatts
With HEEX released we decided to start a components library using Tailwind CSS - check it out here: Petal Components. We also have a boi...
New
sabiwara
Dune is a sandbox for Elixir and aims to safely evaluate user-provided code. You can try it out using this basic Elixir playground made ...
New
Crowdhailer
The latest release of Ace (0.10.0) includes serving content over HTTP/2. I have started writing a webserver to teach my self more about...
New
josevalim
EDIT: since Ecto 3.0 final version is out, this post was amended to use the final versions in the instructions below. Hi everyone, We a...
New
woutdp
Hi! I wanted to introduce my latest project LiveSvelte. It allows you to render Svelte inside LiveView with end-to-end reactivity. It’s ...
New
Qqwy
Hello everyone, I wrote a small library today called MapDiff. It returns a map listing the (smallest amount of) changes to get from map...
New
zorbash
I created Kitto a framework for dashboards inspired by Dashing. [demo] The distributed characteristics of Elixir and the low memory foo...
New
OvermindDL1
I created a new library (rather I pulled out a couple files from my big project), it manages an operating system PID file for the BEAM. ...
New

Other popular topics Top

Qqwy
Update: How to use the Blogs & Podcasts section You can post links to your blog posts or podcasts either in one of the Official Blog...
3268 119930 1237
New
JDanielMartinez
Hi! May someone helps me, please! I have two apps into an umbrella project: the first one is Database, which manages queries, and the se...
New
chrisalley
ExUnit now has describe blocks which is a welcome addition coming from RSpec. In the docs, it states that nested hierarchies of describe ...
New
JakeBecker
TL;DR: I’ve just released an implementation of Microsoft’s IDE-independent Language Server Protocol for Elixir. It adds language support ...
1140 51847 244
New
Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
malloryerik
Hi, this is for people who, like me, have had some friction using .html.heex templates in VSCode. The solution seems to be, in a hyphena...
New
quazar
How to set Jason to encode all fields in ecto schema, I don’t care about security and implementing only is taking long list of attributes...
New
chrismccord
As promised, the first release candidate of Phoenix 1.3.0 is out! This release focuses on code generators with improved project structure...
New
ovidiubadita
Hey all, I discovered Elixir and I love it. I always wanted to learn a functional programming and I intended to go for Haskell, but afte...
New

Sub Categories:

We're in Beta

About us Mission Statement