ipld-eth-server/pkg/transformers/price_feeds/pip/repository.go
2018-08-16 11:22:16 -05:00

26 lines
632 B
Go

package pip
import (
"github.com/vulcanize/vulcanizedb/pkg/datastore/postgres"
"github.com/vulcanize/vulcanizedb/pkg/transformers/price_feeds"
)
type IPipRepository interface {
CreatePip(pip price_feeds.PriceUpdate) error
}
type PipRepository struct {
db *postgres.DB
}
func NewPipRepository(db *postgres.DB) PipRepository {
return PipRepository{
db: db,
}
}
func (repository PipRepository) CreatePip(pip price_feeds.PriceUpdate) error {
_, err := repository.db.Exec(`INSERT INTO maker.pips (block_number, header_id, usd_value) VALUES ($1, $2, $3::NUMERIC)`, pip.BlockNumber, pip.HeaderID, pip.UsdValue)
return err
}