diff --git a/db/price.go b/db/price.go index 798a6e4..81d3368 100644 --- a/db/price.go +++ b/db/price.go @@ -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 } diff --git a/db/total_supply.go b/db/total_supply.go index ba7f7c9..ef108ab 100644 --- a/db/total_supply.go +++ b/db/total_supply.go @@ -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 } diff --git a/db/tvl.go b/db/tvl.go index 35f49f6..eb96400 100644 --- a/db/tvl.go +++ b/db/tvl.go @@ -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 } diff --git a/db/utils.go b/db/utils.go new file mode 100644 index 0000000..f2500d5 --- /dev/null +++ b/db/utils.go @@ -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"` +}