package postgres import ( "github.com/kcotugno/tacitus" "github.com/shopspring/decimal" "database/sql" "errors" "time" ) type AggregationResults struct { rows *sql.Rows aggregation tacitus.Aggregation err error } func (r *AggregationResults) Next() bool { var a tacitus.Aggregation var id, interval, buyTransactions, sellTransactions *int var product *string var price, buyVolume, sellVolume *decimal.Decimal var timestamp *time.Time if r.rows == nil { r.err = errors.New("No query results") return false } if r.rows.Next() { r.err = r.rows.Scan(&id, &interval, &product, &price, &buyVolume, &sellVolume, &buyTransactions, &sellTransactions, ×tamp) if id != nil { a.Id = *id } if interval != nil { a.Interval = *interval } if product != nil { a.Product = *product } if price != nil { a.Price = *price } if buyVolume != nil { a.BuyVolume = *buyVolume } if sellVolume != nil { a.SellVolume = *sellVolume } if buyTransactions != nil { a.BuyTransactions = *buyTransactions } if sellTransactions != nil { a.SellTransactions = *sellTransactions } if timestamp != nil { a.Timestamp = *timestamp } r.aggregation = a } else { r.err = r.rows.Err() return false } if r.err == nil { return true } else { return false } } func (r *AggregationResults) Value() interface{} { return r.aggregation } func (r *AggregationResults) Error() error { return r.err } func (r *AggregationResults) Close() error { if r.rows != nil { return r.rows.Close() } return nil }