From 7771b4b9922a3bc781c2da8752b343ff8122780d Mon Sep 17 00:00:00 2001 From: Cole Brown Date: Tue, 7 Aug 2018 15:29:41 -0400 Subject: [PATCH] Add docstring for txn --- datastore.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/datastore.go b/datastore.go index 085d265..33e36a8 100644 --- a/datastore.go +++ b/datastore.go @@ -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 } @@ -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)} }