2022-08-30 18:05:11 +00:00
|
|
|
package repo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
2022-09-24 19:33:38 +00:00
|
|
|
"github.com/hay-kot/homebox/backend/ent"
|
2022-08-30 18:05:11 +00:00
|
|
|
)
|
|
|
|
|
2022-09-05 08:26:21 +00:00
|
|
|
type GroupRepository struct {
|
2022-08-30 18:05:11 +00:00
|
|
|
db *ent.Client
|
|
|
|
}
|
|
|
|
|
2022-09-05 08:26:21 +00:00
|
|
|
func (r *GroupRepository) Create(ctx context.Context, name string) (*ent.Group, error) {
|
|
|
|
return r.db.Group.Create().
|
|
|
|
SetName(name).
|
|
|
|
Save(ctx)
|
2022-08-30 18:05:11 +00:00
|
|
|
}
|
|
|
|
|
2022-09-05 08:26:21 +00:00
|
|
|
func (r *GroupRepository) GetOneId(ctx context.Context, id uuid.UUID) (*ent.Group, error) {
|
2022-08-31 03:21:18 +00:00
|
|
|
return r.db.Group.Get(ctx, id)
|
2022-08-30 18:05:11 +00:00
|
|
|
}
|