Update db function and add to web-back
This commit is contained in:
		@ -69,8 +69,8 @@ type Transaction struct {
 | 
			
		||||
	Amount              int       `json:"amount"`
 | 
			
		||||
	Currency            string    `json:"currency"`
 | 
			
		||||
	LastFour            string    `json:"last_four"`
 | 
			
		||||
	BankReturnCode      string    `json:bank_return_code`
 | 
			
		||||
	TransactionStatusID int       `json:transaction_status_id`
 | 
			
		||||
	BankReturnCode      string    `json:"bank_return_code"`
 | 
			
		||||
	TransactionStatusID int       `json:"transaction_status_id"`
 | 
			
		||||
	CreatedAt           time.Time `json:"-"`
 | 
			
		||||
	UpdatedAt           time.Time `json:"-"`
 | 
			
		||||
}
 | 
			
		||||
@ -92,10 +92,22 @@ func (m *DBModel) GetWidget(id int) (Widget, error) {
 | 
			
		||||
 | 
			
		||||
	var widget Widget
 | 
			
		||||
 | 
			
		||||
	query := `SELECT id, name FROM widgets WHERE id = ?`
 | 
			
		||||
	query := `SELECT id, name, description, inventory_level, price,
 | 
			
		||||
                     coalesce(image, ''),
 | 
			
		||||
                     created_at, updated_at
 | 
			
		||||
              FROM widgets WHERE id = ?;`
 | 
			
		||||
 | 
			
		||||
	row := m.DB.QueryRowContext(ctx, query, id)
 | 
			
		||||
	err := row.Scan(&widget.ID, &widget.Name)
 | 
			
		||||
	err := row.Scan(
 | 
			
		||||
		&widget.ID,
 | 
			
		||||
		&widget.Name,
 | 
			
		||||
		&widget.Description,
 | 
			
		||||
		&widget.InventoryLevel,
 | 
			
		||||
		&widget.Price,
 | 
			
		||||
		&widget.Image,
 | 
			
		||||
		&widget.CreatedAt,
 | 
			
		||||
		&widget.UpdatedAt,
 | 
			
		||||
	)
 | 
			
		||||
	if err != nil {
 | 
			
		||||
		return widget, err
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
		Reference in New Issue
	
	Block a user