code example correction

This commit is contained in:
2025-07-27 06:12:11 +00:00
parent 63b71692b5
commit d95eea6636

View File

@@ -48,7 +48,10 @@ once you have the schama files created you can use `pgm` as
```go ```go
package main package main
import "code.partial.tech/go/pgm" import (
"code.partial.tech/go/pgm"
"myapp/db/user" // scham create by pgm/cmd
)
type MyModel struct { type MyModel struct {
ID string ID string
@@ -64,8 +67,8 @@ func main() {
// Select query to fetch the first record // Select query to fetch the first record
// Assumes the schema is defined in the "db" package with a User table // Assumes the schema is defined in the "db" package with a User table
var v MyModel var v MyModel
err := db.User.Select(db.User.ID, db.User.Email). err := db.User.Select(user.ID, user.Email).
Where(db.User.Email.Like("anki%")). Where(user.Email.Like("anki%")).
First(context.TODO(), &v.ID, &v.Email) First(context.TODO(), &v.ID, &v.Email)
if err != nil { if err != nil {
println("Error:", err.Error()) println("Error:", err.Error())