Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Expand docs for *Iter.Next #163

Merged
merged 2 commits into from
May 21, 2018
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions session.go
Original file line number Diff line number Diff line change
Expand Up @@ -4265,16 +4265,21 @@ func (iter *Iter) Timeout() bool {
//
// Next returns true if a document was successfully unmarshalled onto result,
// and false at the end of the result set or if an error happened.
// When Next returns false, the Err method should be called to verify if
// there was an error during iteration, and the Timeout method to verify if the
// false return value was caused by a timeout (no available results).
// When Next returns false, either the Err method or the Close method should be
// called to verify if there was an error during iteration. While both will
// return the error (or nil), Close will also release the cursor on the server.
// The Timeout method may also be called to verify if the false return value
// was caused by a timeout (no available results).
//
// For example:
//
// iter := collection.Find(nil).Iter()
// for iter.Next(&result) {
// fmt.Printf("Result: %v\n", result.Id)
// }
// if iter.Timeout() {
// // react to timeout
// }
// if err := iter.Close(); err != nil {
// return err
// }
Expand Down