Skip to content

Commit 2dd7eae

Browse files
committed
Added more result examples
1 parent 536f8c1 commit 2dd7eae

File tree

1 file changed

+20
-1
lines changed

1 file changed

+20
-1
lines changed

README.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ Cursors have a number of methods available for accessing the query results
129129
- `All` retrieves all documents from the result set into the provided slice.
130130
- `One` retrieves the first document from the result se.
131131

132-
Example:
132+
Examples:
133133

134134
```go
135135
var row interface{}
@@ -141,6 +141,25 @@ if res.Err() != nil {
141141
}
142142
```
143143

144+
```go
145+
var rows []interface{}
146+
err := res.All(&rows)
147+
if err != nil {
148+
// error
149+
}
150+
```
151+
152+
```go
153+
var row interface{}
154+
err := res.One(&row)
155+
if err == r.ErrEmptyResult {
156+
// row not found
157+
}
158+
if err != nil {
159+
// error
160+
}
161+
```
162+
144163
## Encoding/Decoding Structs
145164
When passing structs to Expr(And functions that use Expr such as Insert, Update) the structs are encoded into a map before being sent to the server. Each exported field is added to the map unless
146165

0 commit comments

Comments
 (0)