mirror of https://github.com/VinGarcia/ksql.git
Fix code identation on README.md
parent
208ce07d6e
commit
1e434b0b78
24
README.md
24
README.md
|
@ -369,8 +369,8 @@ Querying a single joined row:
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
var row struct{
|
var row struct{
|
||||||
User User `tablename:"u"` // (here the tablename must match the aliased tablename in the query)
|
User User `tablename:"u"` // (here the tablename must match the aliased tablename in the query)
|
||||||
Post Post `tablename:"p"` // (if no alias is used you should use the actual name of the table)
|
Post Post `tablename:"p"` // (if no alias is used you should use the actual name of the table)
|
||||||
}
|
}
|
||||||
err = db.QueryOne(ctx, &row, "FROM users as u JOIN posts as p ON u.id = p.user_id WHERE u.id = ?", userID)
|
err = db.QueryOne(ctx, &row, "FROM users as u JOIN posts as p ON u.id = p.user_id WHERE u.id = ?", userID)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -382,12 +382,12 @@ Querying a page of joined rows:
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
var rows []struct{
|
var rows []struct{
|
||||||
User User `tablename:"u"`
|
User User `tablename:"u"`
|
||||||
Post Post `tablename:"p"`
|
Post Post `tablename:"p"`
|
||||||
}
|
}
|
||||||
err = db.Query(ctx, &rows,
|
err = db.Query(ctx, &rows,
|
||||||
"FROM users as u JOIN posts as p ON u.id = p.user_id WHERE name = ? LIMIT ? OFFSET ?",
|
"FROM users as u JOIN posts as p ON u.id = p.user_id WHERE name = ? LIMIT ? OFFSET ?",
|
||||||
"Cristina", limit, offset,
|
"Cristina", limit, offset,
|
||||||
)
|
)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
|
@ -402,9 +402,9 @@ err = db.QueryChunks(ctx, ksql.ChunkParser{
|
||||||
Params: []interface{}{usersType},
|
Params: []interface{}{usersType},
|
||||||
ChunkSize: 100,
|
ChunkSize: 100,
|
||||||
ForEachChunk: func(rows []struct{
|
ForEachChunk: func(rows []struct{
|
||||||
User User `tablename:"u"`
|
User User `tablename:"u"`
|
||||||
Post Post `tablename:"p"`
|
Post Post `tablename:"p"`
|
||||||
}) error {
|
}) error {
|
||||||
err := sendRowsSomewhere(rows)
|
err := sendRowsSomewhere(rows)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// This will abort the QueryChunks loop and return this error
|
// This will abort the QueryChunks loop and return this error
|
||||||
|
@ -449,12 +449,12 @@ You are not forced to, and there are a few use-cases where you would prefer not
|
||||||
|
|
||||||
```golang
|
```golang
|
||||||
var rows []struct{
|
var rows []struct{
|
||||||
UserName string `ksql:"name"`
|
UserName string `ksql:"name"`
|
||||||
PostTitle string `ksql:"title"`
|
PostTitle string `ksql:"title"`
|
||||||
}
|
}
|
||||||
err := db.Query(ctx, &rows, "SELECT u.name, p.title FROM users u JOIN posts p ON u.id = p.user_id LIMIT 10")
|
err := db.Query(ctx, &rows, "SELECT u.name, p.title FROM users u JOIN posts p ON u.id = p.user_id LIMIT 10")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err.Error())
|
panic(err.Error())
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue