tfogo / mongodb-go-tutorial

Example using the MongoDB Go Driver
https://www.mongodb.com/blog/post/mongodb-go-driver-tutorial
126 stars 38 forks source link

cur(sor) and deleteResult gets nil pointer #2

Closed axcosta closed 5 years ago

axcosta commented 5 years ago

Just a heads up as when executing finding multiple documents and deleting all documents, cursor and deleteResult gets nil pointer when filter is set to nil. If filter is set to bson.D{{}}, then all goes well.

tfogo commented 5 years ago

Thanks @axcosta!

In version 0.1.0 of the driver, you could pass nil as a filter document. I have updated the code so that it's compatible with later versions of the driver that require bson.D{{}} instead.