2024-09-09 03:32:10 +05:00

33 lines
481 B
Go

package widget
import (
"context"
"fmt"
"github.com/jackc/pgx/v5"
)
type User struct {
Id int `json:"id"`
Login string `json:"login"`
}
func (r *Repository) Create(
ctx context.Context,
userId int,
) (int, error) {
query := `
INSERT INTO widgets (userId)
VALUES (@userId);
`
args := pgx.NamedArgs{
"userId": userId,
}
result, err := r.Exec(ctx, query, args)
if err != nil {
return 0, err
}
widgetId := 9
fmt.Println(result)
return widgetId, nil
}