fuelen / composite Goto Github PK
View Code? Open in Web Editor NEWA utility for building dynamic queries in Elixir
License: Apache License 2.0
A utility for building dynamic queries in Elixir
License: Apache License 2.0
Coworker wrote ignore
instead of ignore?
so we can write code like this
|> Composite.param(
:order,
fn
query, :department_name_asc ->
query |> order_by([departments: departments], asc: departments.name)
query, :username_asc ->
query |> order_by(asc: :name)
end,
on_ignore: &order_by(&1, :inserted_at)
)
Getting a strange behavior where the query created with Composite will fail randomly with the error
** (Protocol.UndefinedError) protocol Ecto.Queryable not implemented for %Composite{...}
This does not happen always, but instead randomly without any change in the code. Perhaps the apply function is not being applied automatically?
My query is created as follows:
Schema
|> Composite.new(params)
|> Composite.param([:param1], &filter_by_param1/2)
|> Composite.param([:param2], &filter_by_param2/2, requires: :schema2)
|> Composite.dependency(:plan, &join_schema2/1)
|> Repo.all()
To reiterate, this is working in some cases and some cases is not. There isn't any change between successful and unsuccessful runs.
I'm using composite 0.4.3.
Currently, we have the following API
|> Composite.param(:include_empty, fn query, _ -> query end,
ignore?: &(&1 != true),
on_ignore: &only_nonempty/1
)
The new idea is to allow functions with arity 1, so instead of fn query, _ -> query end
, where passed parameter is not used, we can write &Function.identity/1
or &(&1)
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.