PsychicPlatypus
ExtractQueryParams - A simple elixir package for transforming keyword lists to SQL statements
Motivation
I was building a toy rest-api using plug-cowboy and wanted a way to turn query parameters such as name: "Bob, age: 15 into sql statements such as:
Depo.read("SELECT * FROM customers WHERE" <> "name = ? AND age = ?", "Bob", 15)
in a simple way
Usage
ExtractQueryParams.to_variables(name: "Bob", age: 15)
{"name= ? AND age = ?", ["Bob", 15]} #returns
The default logical operator is AND but you can also specify which operator you want:
ExtractQueryParams.to_variables([name: "Bob", age: 15], "OR")
{"name= ? OR age = ?", ["Bob", 15]} #returns
Feel free to leave any feedback or contribute if you want!
Most Liked
gregvaughn
Are you intentionally wanting to avoid Ecto? With Ecto and a schema defined for Customer creating the query becomes a one-liner
filters = [name: "Bob", age: 15]
query = from c in Customer, where: ^filters
4
Popular in Libraries
I feel kind of stuck with the absence of a proper xml library for Elixir. Currently I use SweetXML which was ok for me more or less to pa...
New
Just looking for a little feedback on a tiny helper library I built -
Sometimes I find the need to convert maps with atom keys to maps...
New
Elixir plugin for JetBrain’s IntelliJ Platform (including Rubymine)
This is a plugin that adds support for Elixir to JetBrains IntelliJ...
New
Leverage Open Api 3.0 (Swagger) to document, test, validate and explore your Plug and Phoenix APIs.
Generate and serve a JSON Open API ...
New
If you would like to migrate away from node/npm/webpack while still using sass, the dart_sass package provides a installer and runner for...
New
Hello everybody.
I have just released Jason - a new JSON library.
You might be wondering, why do we need a new library? The primary foc...
New
I’ve cleaned up and open sourced three financial libraries I was using for my company. They are bindings for the APIs of these three comp...
New
PhoenixWS - Websockets over Phoenix Channels
Source code on Github here: https://github.com/tmbb/phoenix_ws
Phoenix channels are a great...
New
Hello everyone!
I want to share with you something that I’m really proud of: https://stillstatic.io/
Still is a static site builder for...
New
Bandit is an HTTP server for Plug and WebSock apps.
Bandit is written entirely in Elixir and is built atop Thousand Island. It can serve...
New
Other popular topics
How to handle excepions in elixir? Suppose i have A, B, C ,D, E modules. and each module has get() function. A.get() method will call th...
New
Okay, I'm having a heck of a time trying to figure out how to best handle the validation of belongs_to associations in Ecto. I'm sure I'...
New
Credo is smart enough to check for (something like) this:
assert length(the_list) == 0
with this response:
Checking if an enum is empt...
New
In the Dialyzer docs ( http://erlang.org/doc/man/dialyzer.html#requesting-or-suppressing-warnings-in-source-files ), there is a way to tu...
New
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
Hi,
I'm quite new in Elixir and I'm trying to format a string to a PEM format. I have the certificate value like MIIDBTCCAe2...... and ...
New
I have seen a lot of code which picks the first element from a list using Enum.at(0) instead of List.first. Is there a reason why people ...
New
I am using Ecto timestamps with postgres, I can see the timestamps() use the :naive_dateime but for my use case I wanted to store the ti...
New
Hi,
I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
About me? ( if you have nothing better to do than reading about some random guy in the internet :stuck_out_tongue: )
Hello all, this is ...
New







