Skip to content

Commit

Permalink
Rename group / preparation to innet join
Browse files Browse the repository at this point in the history
  • Loading branch information
MichalObi committed Feb 1, 2021
1 parent f304cef commit 682be54
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion BE/cmd/api/handlers/getgroup/getgroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ func getGroup(app *application.Application) httprouter.Handle {
defer r.Body.Close()

id := r.Context().Value(models.CtxKey("groupid"))
group := &models.Group{ID: id.(int)}
group := &models.Group{GroupID: id.(int)}

if err := group.GetByID(r.Context(), app); err != nil {
if errors.Is(err, sql.ErrNoRows) {
Expand Down
12 changes: 6 additions & 6 deletions BE/cmd/api/models/group.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type Position struct {
type PositionSlice []Position

type Group struct {
ID int `json:"id"`
GroupID int `json:"group_id"`
SheetId int `json:"sheet_id"`
Name string `json:"name"`
Positions PositionSlice `json:"positions"`
Expand Down Expand Up @@ -45,15 +45,15 @@ func (g *Group) Create(ctx context.Context, app *application.Application) error
positions
)
VALUES ($1, $2, $3)
RETURNING id`
RETURNING group_id`

err := app.DB.Client.QueryRowContext(
ctx,
stmt,
g.SheetId,
g.Name,
g.Positions,
).Scan(&g.ID)
).Scan(&g.GroupID)

if err != nil {
return err
Expand All @@ -66,14 +66,14 @@ func (g *Group) GetByID(ctx context.Context, app *application.Application) error
stmt := `
SELECT *
FROM groups
WHERE id = $1
WHERE group_id = $1
`
err := app.DB.Client.QueryRowContext(
ctx,
stmt,
g.ID,
g.GroupID,
).Scan(
&g.ID,
&g.GroupID,
&g.SheetId,
&g.Name,
&g.Positions,
Expand Down
2 changes: 1 addition & 1 deletion BE/db/migrations/20210126103639_create_groups.up.sql
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
CREATE TABLE IF NOT EXISTS public.groups
(
sheets_id INT,
id SERIAL PRIMARY KEY,
group_id SERIAL PRIMARY KEY,
name VARCHAR(100) NOT NULL,
positions JSONB NOT NULL,
CONSTRAINT fk_sheets
Expand Down

0 comments on commit 682be54

Please sign in to comment.