Releases: guregu/dynamo
Minor touchups
On-demand and better If
This release adds some new features:
- #87: On-demand (pay per request) billing mode support in CreateTable, UpdateTable, and table Descriptions. Just use
OnDemand(true)
. - #89: You can now call
If
multiple times when using Update, Put, Delete, and ConditionCheck and your conditions will be combined with AND. Formerly, it replaced the previous condition which could lead to buggy behavior.- Additionally,
Filter
in Query and Scan is now careful about adding parentheses so that multiple calls will always have isolated conditions.
- Additionally,
CreateTable fix
This is a minor release that fixes CreateTable not working under certain conditions. See: #88
Transactions
This release adds support for DynamoDB transactions! For a quick and dirty intro to them, see tx_test.go
.
You create transactions by composing pre-existing parts of the library such as Update and Delete.
For example, imagine a game where you can give money to other players. The following transaction models Alice giving 100 gold to Bob and adding a log to a separate table, but only if Alice has enough gold.
tx := db.WriteTx()
users := db.Table("Users")
logs := db.Table("TradeLogs")
amount := 100
tx.Update(users.Update("UserID", "Alice").Add("Gold", -amount).If("Gold >= ?", amount))
tx.Update(users.Update("UserID", "Bob").Add("Gold", amount))
tx.Put(logs.Put(TradeLog{From: "Alice", To: "Bob", Amount: amount, Time: time.Now()}))
err := tx.Run()
If any part of the transaction fails, it will be rolled back and an appropriate error will be returned.
The official AWS Go SDK is still missing some transactions features, and we'll add support for them as they trickle in.
This release also adds support for Go modules.
First versioned release
The API has been relatively stable since the beginning and that API is now officially version 1 🎉
There are still things to add and changes I'd like to make, but rest assured that semver will be upheld.
Thanks to everyone who uses this library.