Dequel

[!WARNING] Under active development. Only nightly pre-release available at the moment.

Dequel (DQL, Data Query Language) is a human-friendly query language that feels familiar to anyone who has used search filters on sites like GitHub, Discord, or Gmail.

# Find blog posts about Elixir from 2024
tags:*"elixir" created:>(2024-01-01)

# Find high-priority tasks assigned to Sarah
priority:"high" assignee:"sarah" status:!="completed"

# Complex filtering using AND/OR logic
(category:"frontend" || category:"design") status:"pending"

Features

Installation

If available in Hex, the package can be installed by adding dequel to your list of dependencies in mix.exs:

def deps do
  [
    {:dequel, "~> 0.0.1-dev"} # current
  ]
end

Getting Started

# Parse a query string into an AST
{:ok, ast} = Dequel.parse("status:active priority:>2")

# Use with Ecto
query = Post |> Dequel.Ecto.filter("tags:*elixir created:>(2024-01-01)")
posts = Repo.all(query)

# Compatible with Ecto's composition API:
user_input = "title:contains(css, html)"

from(Content, where: ^Dequel.where(user_input))
|> where(:status, "published") # include only published content
|> where(:user_id, ^current_user.id) # limit to what a user is allowed to see
|> Repo.all()

Why Dequel?

Dequel provides a query interface that's powerful enough for developers but approachable for end users. It's ideal for:

License

MIT