MCPcopy
hub / github.com/sqlc-dev/sqlc / BooksByTitleYear

Method BooksByTitleYear

examples/booktest/sqlite/query.sql.go:84–114  ·  view source on GitHub ↗
(ctx context.Context, arg BooksByTitleYearParams)

Source from the content-addressed store, hash-verified

82}
83
84func (q *Queries) BooksByTitleYear(ctx context.Context, arg BooksByTitleYearParams) ([]Book, error) {
85 rows, err := q.db.QueryContext(ctx, booksByTitleYear, arg.Title, arg.Yr)
86 if err != nil {
87 return nil, err
88 }
89 defer rows.Close()
90 var items []Book
91 for rows.Next() {
92 var i Book
93 if err := rows.Scan(
94 &i.BookID,
95 &i.AuthorID,
96 &i.Isbn,
97 &i.BookType,
98 &i.Title,
99 &i.Yr,
100 &i.Available,
101 &i.Tag,
102 ); err != nil {
103 return nil, err
104 }
105 items = append(items, i)
106 }
107 if err := rows.Close(); err != nil {
108 return nil, err
109 }
110 if err := rows.Err(); err != nil {
111 return nil, err
112 }
113 return items, nil
114}
115
116const createAuthor = `-- name: CreateAuthor :one
117INSERT INTO authors (name) VALUES (?)

Callers 1

TestBooksFunction · 0.45

Calls 5

QueryContextMethod · 0.65
CloseMethod · 0.65
NextMethod · 0.45
ScanMethod · 0.45
ErrMethod · 0.45

Tested by 1

TestBooksFunction · 0.36