storage

package
v0.3.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 7, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Bunt

type Bunt struct {
	// contains filtered or unexported fields
}

func (*Bunt) CreateOrder

func (b *Bunt) CreateOrder(order *model.Order) error

func (Bunt) Orders

func (b Bunt) Orders(filters ...OrderFilter) ([]*model.Order, error)

func (Bunt) UpdateOrder

func (b Bunt) UpdateOrder(order *model.Order) error

type OrderFilter

type OrderFilter func(model.Order) bool

func WithPair

func WithPair(pair string) OrderFilter

func WithStatus

func WithStatus(status model.OrderStatusType) OrderFilter

func WithStatusIn

func WithStatusIn(status ...model.OrderStatusType) OrderFilter

func WithUpdateAtBeforeOrEqual

func WithUpdateAtBeforeOrEqual(time time.Time) OrderFilter

type SQL

type SQL struct {
	// contains filtered or unexported fields
}

func (*SQL) CreateOrder

func (s *SQL) CreateOrder(order *model.Order) error

CreateOrder creates a new order in a SQL database

func (*SQL) Orders

func (s *SQL) Orders(filters ...OrderFilter) ([]*model.Order, error)

Orders filter a list of orders given a filter

func (*SQL) UpdateOrder

func (s *SQL) UpdateOrder(order *model.Order) error

UpdateOrder updates a given order

type Storage

type Storage interface {
	CreateOrder(order *model.Order) error
	UpdateOrder(order *model.Order) error
	Orders(filters ...OrderFilter) ([]*model.Order, error)
}

func FromFile

func FromFile(file string) (Storage, error)

func FromMemory

func FromMemory() (Storage, error)

func FromSQL

func FromSQL(dialect gorm.Dialector, opts ...gorm.Option) (Storage, error)

FromSQL creates a new SQL connections for orders storage. Example of usage:

import "github.com/glebarez/sqlite"
storage, err := storage.FromSQL(sqlite.Open("sqlite.db"), &gorm.Config{})
if err != nil {
	log.Fatal(err)
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL