Skip to content

Commit

Permalink
refactor: use db selector
Browse files Browse the repository at this point in the history
  • Loading branch information
GalvinGao committed Feb 10, 2023
1 parent 7bb753d commit 1cc9a59
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions internal/repo/time_range.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import (
"github.com/uptrace/bun"

"exusiai.dev/backend-next/internal/model"
"exusiai.dev/backend-next/internal/repo/selector"
)

type TimeRange struct {
db *bun.DB
db *bun.DB
sel selector.S[model.TimeRange]
}

func NewTimeRange(db *bun.DB) *TimeRange {
return &TimeRange{db: db}
return &TimeRange{db: db, sel: selector.New[model.TimeRange](db)}
}

func (r *TimeRange) GetTimeRangesByServer(ctx context.Context, server string) ([]*model.TimeRange, error) {
Expand Down
6 changes: 4 additions & 2 deletions internal/repo/trend_element.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,16 @@ import (
"github.com/uptrace/bun"

"exusiai.dev/backend-next/internal/model"
"exusiai.dev/backend-next/internal/repo/selector"
)

type TrendElement struct {
db *bun.DB
db *bun.DB
sel selector.S[model.TrendElement]
}

func NewTrendElement(db *bun.DB) *TrendElement {
return &TrendElement{db: db}
return &TrendElement{db: db, sel: selector.New[model.TrendElement](db)}
}

func (r *TrendElement) BatchSaveElements(ctx context.Context, elements []*model.TrendElement, server string) error {
Expand Down

0 comments on commit 1cc9a59

Please sign in to comment.