2022-08-30 10:05:11 -08:00
|
|
|
package repo
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
|
|
|
|
"github.com/google/uuid"
|
2022-09-24 11:33:38 -08:00
|
|
|
"github.com/hay-kot/homebox/backend/ent"
|
2022-08-30 10:05:11 -08:00
|
|
|
)
|
|
|
|
|
2022-09-05 00:26:21 -08:00
|
|
|
type GroupRepository struct {
|
2022-08-30 10:05:11 -08:00
|
|
|
db *ent.Client
|
|
|
|
}
|
|
|
|
|
2022-09-05 00:26:21 -08: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 10:05:11 -08:00
|
|
|
}
|
|
|
|
|
2022-09-05 00:26:21 -08:00
|
|
|
func (r *GroupRepository) GetOneId(ctx context.Context, id uuid.UUID) (*ent.Group, error) {
|
2022-08-30 19:21:18 -08:00
|
|
|
return r.db.Group.Get(ctx, id)
|
2022-08-30 10:05:11 -08:00
|
|
|
}
|