Implement produce service

This commit is contained in:
2021-06-20 18:16:33 -04:00
parent c7cbd7df57
commit 0136e616fb
14 changed files with 537 additions and 37 deletions
+24
View File
@@ -0,0 +1,24 @@
# 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
```go
// 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)
```