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 Announcing
I’ve published the first version of my Makeup library. It’s a syntax highlighter for Elixir in the spirit of Pygments, Currently it highl...
New
None of the current solutions worked well for me, so I went ahead and built a user management system from scratch.
This project took far...
New
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
Hi folks,
Few months ago I have announced the proof-of-concept of the library to manipulate the browsers DOM objects directly from Elixi...
New
https://www.conduitframework.com/
The best overview for how things are tied together is this presentation. Modules and functions are pre...
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
Image is an image processing library for Elixir. It is based upon the fabulous vix library that provides a libvips wrapper for Elixir.
I...
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
Lexical
Lexical is a next-generation language server for the Elixir programming language.
Features
Context aware code completion
As-you...
New
Hello all,
I have been working on my proposed project called Tensorflex as part of Google Summer of Code 2018.. Tensorflex can be used f...
New
Other popular topics
To my knowledge, put_in, Map.update etc. all have the one limitation of not automatically creating intermediate keys when needed (for exa...
New
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Hello, how can I check the Phoenix version ?
Thanks !
New
Hello again - after a longish gap I’ve decided I really must dig into Elixir and see what’s been happening here - so I have a few questio...
New
I tried installing
elixir 1.11.2
erlang 23.3.4
via asdf in my zsh shell. Enabled the versions locally and globally.
When I list them ...
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 code below, if the create action is not set to accept “extra_key” as an input, it errors out with a message shown above. Is there ...
New
There are pre-rolled solutions for other frameworks that do work. However, Phoenix does not seem to have these. Have people had good expe...
New
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New
In asking this question I am more interested about the expressiveness of the language itself and less concerned about the availability of...
New







