Skip to content

Commit

Permalink
store: WIP Add paretoOperations
Browse files Browse the repository at this point in the history
  • Loading branch information
nicholaspcr committed Sep 17, 2024
1 parent 0940301 commit 8059a0d
Show file tree
Hide file tree
Showing 3 changed files with 99 additions and 0 deletions.
46 changes: 46 additions & 0 deletions internal/store/gorm/pareto.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
package gorm

import (
"context"

"github.com/nicholaspcr/GoDE/pkg/api/v1"
"gorm.io/gorm"
)

type paretoModel struct {
gorm.Model
UserID uint
User userModel `gorm:"foreignKey:UserID"`

Vectors []vectorModel
}

type paretoStore struct{ *gorm.DB }

func newParetoStore(db *gorm.DB) *paretoStore { return &paretoStore{db} }

func (st *paretoStore) CreatePareto(
ctx context.Context, usr *api.Pareto,
) error {
pareto := paretoModel{}
st.DB.WithContext(ctx).Create(&pareto)
return nil
}

func (st *paretoStore) GetPareto(
ctx context.Context, usrIDs *api.ParetoIDs,
) (*api.Pareto, error) {
return nil, nil
}

func (st *paretoStore) UpdatePareto(
ctx context.Context, usr *api.Pareto, fields ...string,
) error {
return nil
}

func (st *paretoStore) DeletePareto(
ctx context.Context, usrIDs *api.ParetoIDs,
) error {
return nil
}
44 changes: 44 additions & 0 deletions internal/store/gorm/vector.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package gorm

import (
"context"

"github.com/nicholaspcr/GoDE/pkg/api/v1"
"gorm.io/gorm"
)

type vectorModel struct {
gorm.Model
VectorID uint
Vector paretoModel `gorm:"foreignKey:VectorID"`
}

type vectorStore struct{ *gorm.DB }

func newVectorStore(db *gorm.DB) *vectorStore { return &vectorStore{db} }

func (st *vectorStore) CreateVector(
ctx context.Context, usr *api.Vector,
) error {
vector := vectorModel{}
st.DB.WithContext(ctx).Create(&vector)
return nil
}

func (st *vectorStore) GetVector(
ctx context.Context, usrIDs *api.VectorIDs,
) (*api.Vector, error) {
return nil, nil
}

func (st *vectorStore) UpdateVector(
ctx context.Context, usr *api.Vector, fields ...string,
) error {
return nil
}

func (st *vectorStore) DeleteVector(
ctx context.Context, usrIDs *api.VectorIDs,
) error {
return nil
}
9 changes: 9 additions & 0 deletions internal/store/interfaces.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,3 +25,12 @@ type TenantOperations interface {
GetTenant(context.Context, *api.TenantIDs) (*api.Tenant, error)
DeleteTenant(context.Context, *api.TenantIDs) error
}

// ParetoOperations is the interface for the pareto store.
type ParetoOperations interface {
CreatePareto(context.Context, *api.Pareto) error
GetPareto(context.Context, *api.ParetoIDs) error
UpdatePareto(context.Context, *api.Pareto) error
DeletePareto(context.Context, *api.Pareto) error
ListParetos(context.Context, *api.UserIDs) ([]*api.Pareto, error)
}

0 comments on commit 8059a0d

Please sign in to comment.