Skip to content

Commit

Permalink
Merge pull request #89 from hashicorp/dnephin/document-get-prefix-index
Browse files Browse the repository at this point in the history
Document _prefix index matching for queries
  • Loading branch information
dnephin authored Feb 1, 2022
2 parents 0176005 + 55e6bf9 commit 82790a6
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions txn.go
Original file line number Diff line number Diff line change
Expand Up @@ -522,6 +522,10 @@ func (txn *Txn) DeleteAll(table, index string, args ...interface{}) (int, error)
// has updated the result of the query. Since each read transaction
// operates on an isolated snapshot, a new read transaction must be
// started to observe the changes that have been made.
//
// If the value of index ends with "_prefix", FirstWatch will perform a prefix
// match instead of full match on the index. The registered indexer must implement
// PrefixIndexer, otherwise an error is returned.
func (txn *Txn) FirstWatch(table, index string, args ...interface{}) (<-chan struct{}, interface{}, error) {
// Get the index value
indexSchema, val, err := txn.getIndexValue(table, index, args...)
Expand Down Expand Up @@ -558,6 +562,10 @@ func (txn *Txn) FirstWatch(table, index string, args ...interface{}) (<-chan str
// has updated the result of the query. Since each read transaction
// operates on an isolated snapshot, a new read transaction must be
// started to observe the changes that have been made.
//
// If the value of index ends with "_prefix", LastWatch will perform a prefix
// match instead of full match on the index. The registered indexer must implement
// PrefixIndexer, otherwise an error is returned.
func (txn *Txn) LastWatch(table, index string, args ...interface{}) (<-chan struct{}, interface{}, error) {
// Get the index value
indexSchema, val, err := txn.getIndexValue(table, index, args...)
Expand Down Expand Up @@ -750,6 +758,7 @@ func (txn *Txn) Get(table, index string, args ...interface{}) (ResultIterator, e
// The returned ResultIterator's Next() will return the next Previous value.
//
// See the documentation on Get for details on arguments.
//
// See the documentation for ResultIterator to understand the behaviour of the
// returned ResultIterator.
func (txn *Txn) GetReverse(table, index string, args ...interface{}) (ResultIterator, error) {
Expand All @@ -776,6 +785,10 @@ func (txn *Txn) GetReverse(table, index string, args ...interface{}) (ResultIter
// iterator since the radix tree doesn't efficiently allow watching on lower
// bound changes. The WatchCh returned will be nill and so will block forever.
//
// If the value of index ends with "_prefix", LowerBound will perform a prefix match instead of
// a full match on the index. The registered index must implement PrefixIndexer,
// otherwise an error is returned.
//
// See the documentation for ResultIterator to understand the behaviour of the
// returned ResultIterator.
func (txn *Txn) LowerBound(table, index string, args ...interface{}) (ResultIterator, error) {
Expand Down

0 comments on commit 82790a6

Please sign in to comment.