repo: add some more sql for events

This commit is contained in:
Muyao CHEN
2024-10-18 21:41:53 +02:00
parent dde4eb337c
commit a55fd26f90
4 changed files with 60 additions and 5 deletions

View File

@ -56,3 +56,9 @@ GROUP BY
e.total_amount, e.default_currency,
o.id, o.first_name, o.last_name;
-- name: UpdateEventByID :exec
UPDATE "event"
SET name = $2, description = $3, updated_at = $4
WHERE id = $1;

View File

@ -172,3 +172,26 @@ func (q *Queries) ListEventsByUserID(ctx context.Context, userID int32) ([]ListE
}
return items, nil
}
const updateEventByID = `-- name: UpdateEventByID :exec
UPDATE "event"
SET name = $2, description = $3, updated_at = $4
WHERE id = $1
`
type UpdateEventByIDParams struct {
ID int32
Name string
Description sql.NullString
UpdatedAt time.Time
}
func (q *Queries) UpdateEventByID(ctx context.Context, arg UpdateEventByIDParams) error {
_, err := q.db.ExecContext(ctx, updateEventByID,
arg.ID,
arg.Name,
arg.Description,
arg.UpdatedAt,
)
return err
}

View File

@ -5,6 +5,7 @@
package sqlc
import (
"database/sql"
"time"
)
@ -15,6 +16,26 @@ type Admin struct {
AccessLevel int32
}
type Event struct {
ID int32
Name string
Description sql.NullString
DefaultCurrency string
OwnerID int32
CreatedAt time.Time
UpdatedAt time.Time
TotalAmount sql.NullInt32
}
type Participation struct {
ID int32
UserID int32
EventID int32
InvitedByUserID sql.NullInt32
CreatedAt time.Time
UpdatedAt time.Time
}
type User struct {
ID int32
Email string