Archived
1
This repository has been archived on 2022-11-04. You can view files and clone it, but cannot push or open issues or pull requests.
i2_bot/lib/orders/getters.go

35 lines
786 B
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package orders
import (
"git.wtfteam.pro/fat0troll/i2_bot/lib/dbmapping"
)
// GetAllOrders returns all orders in database
func (o *Orders) GetAllOrders() ([]dbmapping.Order, bool) {
orders := []dbmapping.Order{}
err := c.Db.Select(&orders, "SELECT * FROM orders ORDER BY created_at asc")
if err != nil {
c.Log.Error(err)
return orders, false
}
return orders, true
}
// GetOrderByID returns single order by ID
func (o *Orders) GetOrderByID(orderID int) (dbmapping.Order, bool) {
order := dbmapping.Order{}
err := c.Db.Get(&order, c.Db.Rebind("SELECT * FROM orders WHERE id=?"), orderID)
if err != nil {
c.Log.Error(err.Error())
return order, false
}
return order, true
}