produce

package
v0.0.0-...-af80e91 Latest Latest
Warning

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

Go to latest
Published: Jun 21, 2021 License: GPL-3.0 Imports: 4 Imported by: 0

README

Produce Service

This produce service allows persisting produce in a database. It supports adding multiple produce items, removing a produce item, getting a produce item by produce code, and selecting all produce items from the database.

Example

// Create database and table.
db := ramdb.NewDatabase()
_ = db.CreateTable("produce", KeyProduceCode)

produceSvc := produce.NewService(db)

produceItem := produce.Item{
	Code: "A12T-4GH7-QPL9-3N4M",
	Name: "Lettuce",
	Price: money.New(346, "USD"),
}

_ = produceSvc.Add([]Item{produceItem})
_, _ = produceSvc.Get(produceItem.Code)
_, _ = produceSvc.All()
_ = produceSvc.Remove(produceItem)

Documentation

Index

Constants

View Source
const (
	KeyProduceCode = "produce_code"
)

Variables

This section is empty.

Functions

func NewService

func NewService(db interfaces.RamDB) *service

NewService creates a new produce service for storing produce items.

Types

type Item

type Item struct {
	Code  string       `json:"code"`
	Name  string       `json:"name"`
	Price *money.Money `json:"price"`
}

Item models a produce item.

Jump to

Keyboard shortcuts

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