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

35 lines
781 B
Go
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// i2_bot Instinct PokememBro Bot
// Copyright (c) 2017 Vladimir "fat0troll" Hodakov
package orders
import (
"github.com/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
}