liveBook · Manning

Read-write transaction

As explained in Build and Orchestrator in Go (From Scratch)

A read-write transaction is a database transaction that can read existing data and modify persistent data.

A read-write transaction opens a consistent database operation that may inspect persistent data and modify it. In BoltDB, Update supplies the transaction through a callback; changes such as creating buckets or storing values occur inside that callback and return an error. section 11.9

Creating a bucket

func (t *TaskStore) CreateBucket() error { return t.Db.Update(func(tx *bolt.Tx) error { _, err := tx.CreateBucket([]byte(t.Bucket)) return err }) }

How Build and Orchestrator in Go (From Scratch) covers it

How deep it goes
Explains the Update callback and error flow through bucket creation and value storage, without detailing transaction internals.
Examples
Demonstrates creating a task bucket and storing JSON-serialized tasks in it.
What it assumes
Assumes familiarity with Go callbacks, errors, buckets, and a file-backed task store.
What you can do after
Apply it via BoltDB Update to implement persistent bucket creation and task writes.
How it connects
Connects database transactions with persistent storage, buckets, key-value writes, and read-only transactions.

This explainer was generated by Manning's knowledge graph from the text of Build and Orchestrator in Go (From Scratch). The section links point to the parts of the book it draws on.