35 lines
541 B
Go
35 lines
541 B
Go
package create
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
"github.com/jackc/pgx/v5"
|
|
pg "template/db/pg"
|
|
)
|
|
|
|
type User struct {
|
|
Id int `json:"id"`
|
|
Login string `json:"login"`
|
|
}
|
|
|
|
func RegUserRepository(
|
|
ctx context.Context,
|
|
login, email *string,
|
|
password string,
|
|
) error {
|
|
query := `
|
|
INSERT INTO users (login, password)
|
|
VALUES (@login, @password);
|
|
`
|
|
args := pgx.NamedArgs{
|
|
"login": login,
|
|
"password": password,
|
|
}
|
|
result, err := pg.Pool.Db.Exec(ctx, query, args)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
fmt.Println(result)
|
|
return nil
|
|
}
|