Skip to content

Commit

Permalink
Add docstring for txn
Browse files Browse the repository at this point in the history
  • Loading branch information
bigs committed Aug 7, 2018
1 parent a05dd3e commit 7771b4b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions datastore.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ type Datastore struct {
gcDiscardRatio float64
}

// Implements the datastore.Txn interface, enabling transaction support for
// the badger Datastore.
type txn struct {
txn *badger.Txn
}
Expand Down Expand Up @@ -73,6 +75,9 @@ func NewDatastore(path string, options *Options) (*Datastore, error) {
}, nil
}

// NewTransaction starts a new transaction. The resulting transaction object
// can be mutated without incurring changes to the underlying Datastore until
// the transaction is Committed.
func (d *Datastore) NewTransaction(readOnly bool) ds.Txn {
return &txn{d.DB.NewTransaction(!readOnly)}
}
Expand Down

0 comments on commit 7771b4b

Please sign in to comment.