|
The "fully runnable example" from the Find Multiple Documents usage example page declares the results slice that is passed to `cursor.All` as
In the case of no results, `results` will remain in an uninitialized state, which will be encoded as `null` in JSON (and BSON).
In contrast, if the results slice is declared as
var results []bson.M = make([]bson.M, 0, 0)
|
// or, equivalently
|
results := make([]bson.M, 0, 0)
|
In the case of no results, `results` will be fully initialized, and will be encoded as `[]` (the empty array) in JSON.
Need to initialize a nil slice in `cursor.All` when there are no results.
|