Added plan of tests
This commit is contained in:
@@ -0,0 +1,31 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.16.0
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
"database/sql"
|
||||
)
|
||||
|
||||
type DBTX interface {
|
||||
ExecContext(context.Context, string, ...interface{}) (sql.Result, error)
|
||||
PrepareContext(context.Context, string) (*sql.Stmt, error)
|
||||
QueryContext(context.Context, string, ...interface{}) (*sql.Rows, error)
|
||||
QueryRowContext(context.Context, string, ...interface{}) *sql.Row
|
||||
}
|
||||
|
||||
func New(db DBTX) *Queries {
|
||||
return &Queries{db: db}
|
||||
}
|
||||
|
||||
type Queries struct {
|
||||
db DBTX
|
||||
}
|
||||
|
||||
func (q *Queries) WithTx(tx *sql.Tx) *Queries {
|
||||
return &Queries{
|
||||
db: tx,
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.16.0
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"time"
|
||||
)
|
||||
|
||||
type Student struct {
|
||||
ID int64
|
||||
Fname string
|
||||
Lname string
|
||||
DateOfBirth time.Time
|
||||
Email string
|
||||
Address string
|
||||
Gender string
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
-- name: FetchStudents :many
|
||||
SELECT * FROM students LIMIT ?;
|
||||
@@ -0,0 +1,45 @@
|
||||
// Code generated by sqlc. DO NOT EDIT.
|
||||
// versions:
|
||||
// sqlc v1.16.0
|
||||
// source: query.sql
|
||||
|
||||
package sqlc
|
||||
|
||||
import (
|
||||
"context"
|
||||
)
|
||||
|
||||
const fetchStudents = `-- name: FetchStudents :many
|
||||
SELECT id, fname, lname, date_of_birth, email, address, gender FROM students LIMIT ?
|
||||
`
|
||||
|
||||
func (q *Queries) FetchStudents(ctx context.Context, limit int32) ([]Student, error) {
|
||||
rows, err := q.db.QueryContext(ctx, fetchStudents, limit)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
defer rows.Close()
|
||||
var items []Student
|
||||
for rows.Next() {
|
||||
var i Student
|
||||
if err := rows.Scan(
|
||||
&i.ID,
|
||||
&i.Fname,
|
||||
&i.Lname,
|
||||
&i.DateOfBirth,
|
||||
&i.Email,
|
||||
&i.Address,
|
||||
&i.Gender,
|
||||
); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
items = append(items, i)
|
||||
}
|
||||
if err := rows.Close(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
if err := rows.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return items, nil
|
||||
}
|
||||
@@ -0,0 +1,10 @@
|
||||
CREATE TABLE `students` (
|
||||
`id` bigint NOT NULL AUTO_INCREMENT,
|
||||
`fname` varchar(50) not null,
|
||||
`lname` varchar(50) not null,
|
||||
`date_of_birth` datetime not null,
|
||||
`email` varchar(50) not null,
|
||||
`address` varchar(50) not null,
|
||||
`gender` varchar(50) not null,
|
||||
PRIMARY KEY (`id`)
|
||||
);
|
||||
@@ -0,0 +1,7 @@
|
||||
version: 1
|
||||
packages:
|
||||
- path: "./"
|
||||
name: "sqlc"
|
||||
engine: "mysql"
|
||||
schema: "schema.sql"
|
||||
queries: "query.sql"
|
||||
Reference in New Issue
Block a user