Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: fix examples #1608

Merged
merged 2 commits into from
May 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions docs/howto/insert.md
Original file line number Diff line number Diff line change
Expand Up @@ -154,11 +154,11 @@ INSERT INTO authors (name, bio) VALUES ($1, $2);

```go
type CreateAuthorsParams struct {
Name string
Bio string
Name string
Bio string
}

func (q *Queries) CreateAuthors(ctx context.Context, arg []CreateAuthorsParams) (int64, error) {
return q.db.CopyFrom(ctx, []string{"authors"}, []string{"name", "bio"}, &iteratorForCreateAuthors{rows: arg})
return q.db.CopyFrom(ctx, []string{"authors"}, []string{"name", "bio"}, &iteratorForCreateAuthors{rows: arg})
}
```
4 changes: 2 additions & 2 deletions docs/howto/transactions.md
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ func (q *Queries) GetRecord(ctx context.Context, id int) (Record, error) {
With pgx you'd use it like this for example:

```go
function bumpCounter(ctx context.Context, p *pgx.Conn, id int) error {
func bumpCounter(ctx context.Context, p *pgx.Conn, id int) error {
tx, err := db.Begin(ctx)
if err != nil {
return err
Expand All @@ -71,7 +71,7 @@ function bumpCounter(ctx context.Context, p *pgx.Conn, id int) error {
}
if err := q.UpdateRecord(ctx, db.UpdateRecordParams{
ID: r.ID,
Counter: r.Counter+1,
Counter: r.Counter + 1,
}); err != nil {
return err
}
Expand Down
13 changes: 8 additions & 5 deletions docs/reference/query-annotations.md
Original file line number Diff line number Diff line change
Expand Up @@ -130,9 +130,10 @@ WHERE book_id = $1;

```go
type DeleteBookBatchResults struct {
br pgx.BatchResults
br pgx.BatchResults
ind int
}

func (q *Queries) DeleteBook(ctx context.Context, bookID []int32) *DeleteBookBatchResults {
//...
}
Expand Down Expand Up @@ -161,13 +162,14 @@ WHERE title = $1 AND year = $2;

```go
type BooksByTitleYearBatchResults struct {
br pgx.BatchResults
br pgx.BatchResults
ind int
}
type BooksByTitleYearParams struct {
Title string `json:"title"`
Year int32 `json:"year"`
}

func (q *Queries) BooksByTitleYear(ctx context.Context, arg []BooksByTitleYearParams) *BooksByTitleYearBatchResults {
//...
}
Expand Down Expand Up @@ -202,13 +204,14 @@ RETURNING book_id, author_id, isbn

```go
type CreateBookBatchResults struct {
br pgx.BatchResults
br pgx.BatchResults
ind int
}
type CreateBookParams struct {
AuthorID int32 `json:"author_id"`
Isbn string `json:"isbn"`
AuthorID int32 `json:"author_id"`
Isbn string `json:"isbn"`
}

func (q *Queries) CreateBook(ctx context.Context, arg []CreateBookParams) *CreateBookBatchResults {
//...
}
Expand Down