https://github.com/guesant/consulta-qb
https://github.com/guesant/consulta-qb
json-schema query query-builder specification sql
Last synced: 3 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/guesant/consulta-qb
- Owner: guesant
- License: mit
- Created: 2023-05-10T19:34:58.000Z (about 2 years ago)
- Default Branch: dev
- Last Pushed: 2023-05-26T14:38:03.000Z (about 2 years ago)
- Last Synced: 2025-03-07T16:41:49.665Z (3 months ago)
- Topics: json-schema, query, query-builder, specification, sql
- Language: TypeScript
- Homepage:
- Size: 135 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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