MCPcopy Index your code
hub / github.com/sqlc-dev/sqlc / BooksByTitleYear

Method BooksByTitleYear

examples/booktest/postgresql/query.sql.go:70–97  ·  view source on GitHub ↗
(ctx context.Context, arg BooksByTitleYearParams)

Source from the content-addressed store, hash-verified

68}
69
70func (q *Queries) BooksByTitleYear(ctx context.Context, arg BooksByTitleYearParams) ([]Book, error) {
71 rows, err := q.db.Query(ctx, booksByTitleYear, arg.Title, arg.Year)
72 if err != nil {
73 return nil, err
74 }
75 defer rows.Close()
76 var items []Book
77 for rows.Next() {
78 var i Book
79 if err := rows.Scan(
80 &i.BookID,
81 &i.AuthorID,
82 &i.Isbn,
83 &i.BookType,
84 &i.Title,
85 &i.Year,
86 &i.Available,
87 &i.Tags,
88 ); err != nil {
89 return nil, err
90 }
91 items = append(items, i)
92 }
93 if err := rows.Err(); err != nil {
94 return nil, err
95 }
96 return items, nil
97}
98
99const createAuthor = `-- name: CreateAuthor :one
100INSERT INTO authors (name) VALUES ($1)

Callers 1

TestBooksFunction · 0.45

Calls 5

QueryMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.45
ScanMethod · 0.45
ErrMethod · 0.45

Tested by 1

TestBooksFunction · 0.36