Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/guesant/consulta-qb


https://github.com/guesant/consulta-qb

json-schema query query-builder specification sql

Last synced: 12 days ago
JSON representation

Awesome Lists containing this project

README

        

# consulta-qb

The goal of consulta-qb is allow to write relational database queries using a declarative language.

## Examples

```json
{
"select": {
"from": "post",
"columns": [
{
"column": {
"table": "post",
"name": "id"
}
},
{
"value": {
"column": {
"table": "\"user\"",
"name": "id"
}
},
"as": "Id of the author"
}
],
"joins": [
{
"mode": "inner",
"table": "\"user\"",
"on": {
"==": [
{
"column": {
"table": "\"user\"",
"name": "id"
}
},
{
"column": {
"table": "post",
"name": "id_author"
}
}
]
}
}
],
"where": {
">": [
{
"column": {
"table": "post",
"name": "published_at"
}
},
{
"literal": "2023-01-01"
}
]
}
}
}
```

### Why?

It's true that the declarative ways adds an overhead (larger size, too verbose etc).

On other hand, in the cases of when is needed to allow queries from user input in some way, it's trustworthy to specify what the query can do and not. This could prevent malicious and unintentional injections.

## License

MIT