forked from mirrors/homebox
align types with new db schema
This commit is contained in:
parent
63cfeffc4d
commit
b83505104a
30 changed files with 1491 additions and 263 deletions
29
backend/internal/repo/repo_group.go
Normal file
29
backend/internal/repo/repo_group.go
Normal file
|
@ -0,0 +1,29 @@
|
|||
package repo
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/google/uuid"
|
||||
"github.com/hay-kot/content/backend/ent"
|
||||
)
|
||||
|
||||
type EntGroupRepository struct {
|
||||
db *ent.Client
|
||||
}
|
||||
|
||||
func (r *EntGroupRepository) Create(ctx context.Context, name string) (*ent.Group, error) {
|
||||
dbGroup, err := r.db.Group.Create().SetName(name).Save(ctx)
|
||||
|
||||
if err != nil {
|
||||
return dbGroup, err
|
||||
}
|
||||
return dbGroup, nil
|
||||
}
|
||||
|
||||
func (r *EntGroupRepository) GetOneId(ctx context.Context, id uuid.UUID) (*ent.Group, error) {
|
||||
dbGroup, err := r.db.Group.Get(ctx, id)
|
||||
if err != nil {
|
||||
return dbGroup, err
|
||||
}
|
||||
return dbGroup, nil
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue