Selecto is a query builder, and SelectoComponents is a liveview based UI to build and view queries.
Example app: SelectoTest · Phoenix Framework
These are still very new, and probably have many bugs. There are many errors unhandled, and many tests as yet unwritten.
I have created Selecto as a side project to a side project. I am new-ish to Elixir and working on my first serious phoenix app. I find that I need a way to provide search/view of several different sets of joined tables for a management interface. Selecto is inspired by a system I created in Perl in 2004, which has been used very successfully ever since. There is a list of planned features in the SelectoComponents readme, most of which are in-use on the Perl system. There is also a list of planned features in the Selecto readme.
You may find this library useful if you are in need of a query/report writing system without a lot of boilerplate. It is very simple to setup a new domain and provide an interface that allows selecting data, building complex filters, and grouping/aggregate.
I am hoping to find some collaborators. I am particularly in need of help with design / styling of the liveview! Also I am new to Elixir, Liveview, and publishing open source software, and I appreciate any help I can get. There are many planned features which I would be happy to have help with as well.
Selecto gathers most of its configuration from Ecto schemas. You create a Domain structure which gives a starting table and a tree of joins that are allowed. (currently, you must provide direct joins- through is not yet supported) Selecto will examine the schema and create it’s configuration.
These examples are from the livebook in selecto_test
Example Domain:
domain = %{
joins: [
planets: %{
name: "Planet",
joins: [
satellites: %{
name: "Satellites"
}
],
}
],
name: "Solar System",
required_filters: [{"id", [1, 2, 3, 4, 5, 6]}], ### filters are required right now
source: SelectoTest.Test.SolarSystem
Create a Selecto struct:
selecto = Selecto.configure(SelectoTest.Repo, domain)
Simple Query:
{results, aliases} =
selecto
|> Selecto.filter({"id", 1})
|> Selecto.select(["planets[name]", "planets[mass]"])
|> Selecto.execute()
Query with ‘OR’
{results, aliases} =
Selecto.filter(
selecto,
{:or,
[
{"planets[name]", "Earth"},
{"planets[name]", "Venus"}
]}
)
|> Selecto.select(["planets[id]", "planets[name]"])
|> Selecto.execute()