-
Type: Improvement
-
Resolution: Duplicate
-
Priority: Major - P3
-
None
-
Affects Version/s: 0.2.0
-
Component/s: Documentation
-
None
-
Environment:Operating system:macOS Mojave ver 10.14.2
Golang version: go1.11.4 darwin/amd64
All the documentation and examples given describe a nil type can be passed as a parameter however when doing so the output is:
$ go run main.go
ID ObjectID("5c454e3cfd1361d7957038bf")
2019/01/21 14:44:44 bigerr: %sdocument is nil
exit status 1
The error comes from a call to collection.Find()
// cant pass nil // filter := bson.D{} cur, err := collection.Find(context.Background(), nil) if err != nil { log.Fatal("bigerr: %s", err) }
collection.Find() passes the filter value downard to transformDocument()
And subsequently it is checked and if the value is nil it is returned.
if val == nil { return nil, ErrNilDocument }
It would make sense to be able to pass a nil to filter to get all the results from a colleciton however passing an empty bson.D{} object works also.
- duplicates
-
GODRIVER-757 README out of date WRT using nil in Find
- Closed