View executes a function creating and managing a read-only transaction for the user. Error returned by the function is relayed by the View method. If View is used with managed transactions, it would assume a read timestamp of MaxUint64.
(fn func(txn *Txn) error)
| 788 | // returned by the function is relayed by the View method. |
| 789 | // If View is used with managed transactions, it would assume a read timestamp of MaxUint64. |
| 790 | func (db *DB) View(fn func(txn *Txn) error) error { |
| 791 | var txn *Txn |
| 792 | if db.opt.managedTxns { |
| 793 | txn = db.NewTransactionAt(math.MaxUint64, false) |
| 794 | } else { |
| 795 | txn = db.NewTransaction(false) |
| 796 | } |
| 797 | defer txn.Discard() |
| 798 | |
| 799 | return fn(txn) |
| 800 | } |
| 801 | |
| 802 | // Update executes a function, creating and managing a read-write transaction |
| 803 | // for the user. Error returned by the function is relayed by the Update method. |