feat: add feature based structure

This commit is contained in:
Justin Lin
2025-08-26 19:18:35 +10:00
commit d963362711
15 changed files with 436 additions and 0 deletions

32
tutorial/db.go Normal file
View File

@@ -0,0 +1,32 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
package tutorial
import (
"context"
"github.com/jackc/pgx/v5"
"github.com/jackc/pgx/v5/pgconn"
)
type DBTX interface {
Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
Query(context.Context, string, ...interface{}) (pgx.Rows, error)
QueryRow(context.Context, string, ...interface{}) pgx.Row
}
func New(db DBTX) *Queries {
return &Queries{db: db}
}
type Queries struct {
db DBTX
}
func (q *Queries) WithTx(tx pgx.Tx) *Queries {
return &Queries{
db: tx,
}
}

15
tutorial/models.go Normal file
View File

@@ -0,0 +1,15 @@
// Code generated by sqlc. DO NOT EDIT.
// versions:
// sqlc v1.29.0
package tutorial
import (
"github.com/jackc/pgx/v5/pgtype"
)
type Author struct {
ID int64
Name string
Bio pgtype.Text
}