mirror of https://github.com/VinGarcia/ksql.git
Add a feature list to the README file
parent
9311b4a17d
commit
fae106916c
39
README.md
39
README.md
|
@ -22,11 +22,20 @@ useful in some situations.
|
|||
In this README you will find examples for "Getting Started" with the library,
|
||||
for more advanced use-cases [please read our Wiki](https://github.com/VinGarcia/ksql/wiki).
|
||||
|
||||
## Outstanding Features
|
||||
|
||||
- Every operation returns errors a single time, so its easier to handle them
|
||||
- Helper functions for everyday operations, namely: Insert, Patch and Delete
|
||||
- Generic and powerful functions for Querying and Scanning data into structs
|
||||
- Works on top of existing battle-tested libraries such as `database/sql` and `pgx`
|
||||
- Supports `sql.Scanner` and `sql.Valuer` and also all `pgx` special types (when using `kpgx`)
|
||||
- And many other features designed to make your life easier
|
||||
|
||||
## Let's start with some Code:
|
||||
|
||||
This short example below is a TLDR version for illustrating how easy it is to use KSQL.
|
||||
This short example below is a TLDR version to illustrate how easy it is to use KSQL.
|
||||
|
||||
You will find more complete examples on the sections below.
|
||||
You will find more complete examples in the sections below.
|
||||
|
||||
```golang
|
||||
package main
|
||||
|
@ -100,7 +109,7 @@ and it is also used for making it easy to mock the whole library if needed.
|
|||
This interface is declared in the project as `ksql.Provider` and is displayed below.
|
||||
|
||||
We plan on keeping it very simple with a small number
|
||||
of well thought functions that cover all use-cases,
|
||||
of well-thought functions that cover all use cases,
|
||||
so don't expect many additions:
|
||||
|
||||
```go
|
||||
|
@ -124,7 +133,7 @@ type Provider interface {
|
|||
|
||||
## Using KSQL
|
||||
|
||||
In the example below we'll cover all the most common use-cases such as:
|
||||
In the example below we'll cover all the most common use cases such as:
|
||||
|
||||
1. Inserting records
|
||||
2. Updating records
|
||||
|
@ -139,7 +148,7 @@ More advanced use cases are illustrated on their own pages on [our Wiki](https:/
|
|||
- [Reusing Existing Structs on Queries with JOINs](https://github.com/VinGarcia/ksql/wiki/Reusing-Existing-Structs-on-Queries-with-JOINs)
|
||||
- [Testing Tools and `ksql.Mock`](https://github.com/VinGarcia/ksql/wiki/Testing-Tools-and-ksql.Mock)
|
||||
|
||||
For the more common use-cases please read the example below,
|
||||
For the more common use cases please read the example below,
|
||||
which is also available [here](./examples/crud/crud.go)
|
||||
if you want to compile it yourself.
|
||||
|
||||
|
@ -342,7 +351,7 @@ func main() {
|
|||
|
||||
The results of the benchmark are good:
|
||||
they show that KSQL is in practical terms,
|
||||
as fast as sqlx which was our goal from the start.
|
||||
as fast as `sqlx` which was our goal from the start.
|
||||
|
||||
To understand the benchmark below you must know
|
||||
that all tests are performed using Postgres 12.1 and
|
||||
|
@ -357,17 +366,17 @@ that we are comparing the following tools:
|
|||
- `sqlc`
|
||||
- `sqlboiler`
|
||||
|
||||
For each of these tools we are running 3 different queries:
|
||||
For each of these tools, we are running 3 different queries:
|
||||
|
||||
The `insert-one` query looks like:
|
||||
The `insert-one` query looks like this:
|
||||
|
||||
`INSERT INTO users (name, age) VALUES ($1, $2) RETURNING id`
|
||||
|
||||
The `single-row` query looks like:
|
||||
The `single-row` query looks like this:
|
||||
|
||||
`SELECT id, name, age FROM users OFFSET $1 LIMIT 1`
|
||||
|
||||
The `multiple-rows` query looks like:
|
||||
The `multiple-rows` query looks like this:
|
||||
|
||||
`SELECT id, name, age FROM users OFFSET $1 LIMIT 10`
|
||||
|
||||
|
@ -438,7 +447,7 @@ which means that:
|
|||
```
|
||||
And then restart your login session (or just reboot)
|
||||
|
||||
After that you can just run the tests by using:
|
||||
After that, you can just run the tests by using:
|
||||
|
||||
```bash
|
||||
make test
|
||||
|
@ -452,7 +461,7 @@ docker pull mysql:8.0.27
|
|||
docker pull mcr.microsoft.com/mssql/server:2017-latest
|
||||
```
|
||||
|
||||
Otherwise the first attempt to run the tests will
|
||||
Otherwise, the first attempt to run the tests will
|
||||
spend a long time downloading these images
|
||||
and then fail because the `TestMain()` function
|
||||
is configured to kill the containers after 20 seconds.
|
||||
|
@ -462,12 +471,12 @@ is configured to kill the containers after 20 seconds.
|
|||
- Update `ksqltest.FillStructWith` to work with `ksql:"..,json"` tagged attributes
|
||||
- Improve error messages (ongoing)
|
||||
|
||||
## Optimization Oportunities
|
||||
## Optimization Opportunities
|
||||
|
||||
- Test if using a pointer on the field info is faster or not
|
||||
- Consider passing the cached structInfo as argument for all the functions that use it,
|
||||
- Consider passing the cached structInfo as an argument for all the functions that use it,
|
||||
so that we don't need to get it more than once in the same call.
|
||||
- Use a cache to store often used queries (like pgx)
|
||||
- Use a cache to store often-used queries (like pgx)
|
||||
- Preload the insert method for all dialects inside `ksql.NewTable()`
|
||||
- Use prepared statements for the helper functions, `Update`, `Insert` and `Delete`.
|
||||
|
||||
|
|
Loading…
Reference in New Issue