Skip to content

Commit

Permalink
move to custom model type which indexed created_at
Browse files Browse the repository at this point in the history
  • Loading branch information
bonedaddy committed Jan 15, 2021
1 parent f533eac commit fe8d0e5
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 9 deletions.
4 changes: 1 addition & 3 deletions db/price.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,11 @@ import (
"errors"
"math"
"time"

"gorm.io/gorm"
)

// Price is a given price entry for an asset
type Price struct {
gorm.Model
Model
Type Asset `gorm:"varchar(255)"`
USDPrice float64
}
Expand Down
4 changes: 1 addition & 3 deletions db/total_supply.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package db

import "gorm.io/gorm"

// TotalSupply is used to track the total supply of a given asset
type TotalSupply struct {
gorm.Model
Model
Type string
Supply float64
}
Expand Down
4 changes: 1 addition & 3 deletions db/tvl.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package db

import "gorm.io/gorm"

// TotalValueLocked records the USD value of funds locked within index pool
type TotalValueLocked struct {
gorm.Model
Model
PoolName string
ValueLocked float64
}
Expand Down
15 changes: 15 additions & 0 deletions db/utils.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
package db

import (
"time"

"gorm.io/gorm"
)

// Model is a copy of the gorm model type but using slightly different configurations
type Model struct {
ID uint `gorm:"primarykey"`
CreatedAt time.Time `gorm:"index"` // this is changed to include the index
UpdatedAt time.Time
DeletedAt gorm.DeletedAt `gorm:"index"`
}

0 comments on commit fe8d0e5

Please sign in to comment.