mirror of
https://github.com/mjl-/mox.git
synced 2025-07-10 06:34:40 +03:00
update to latest bstore
This commit is contained in:
25
vendor/github.com/mjl-/bstore/query.go
generated
vendored
25
vendor/github.com/mjl-/bstore/query.go
generated
vendored
@ -4,6 +4,7 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"iter"
|
||||
"reflect"
|
||||
"slices"
|
||||
|
||||
@ -1233,3 +1234,27 @@ func (q *Query[T]) ForEach(fn func(value T) error) (rerr error) {
|
||||
return fn(v)
|
||||
})
|
||||
}
|
||||
|
||||
// All returns an iterator over all selected records.
|
||||
//
|
||||
// All automatically respositions the cursor when data is changed while iterating.
|
||||
// Changes to data aren't necessarily reflected in the yielded values. This can
|
||||
// happen when a sort order isn't executed using an index: All gathers and sorts (a
|
||||
// subset of) values before yielding them and does not reapply filtering and does
|
||||
// not necessarily yield the updated values.
|
||||
func (q *Query[T]) All() iter.Seq2[T, error] {
|
||||
return func(yield func(T, error) bool) {
|
||||
var stopped bool
|
||||
err := q.ForEach(func(v T) error {
|
||||
if !yield(v, nil) {
|
||||
stopped = true
|
||||
return StopForEach
|
||||
}
|
||||
return nil
|
||||
})
|
||||
if !stopped && err != nil {
|
||||
var zero T
|
||||
yield(zero, err)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user