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!