Announcing mgo r2011.05.12 with map/reduce support

Skip to first unread message

Gustavo Niemeyer

May 12, 2011, 2:24:51 AM5/12/11
to golang-nuts,,
The r2011.05.12 release of the mgo MongoDB driver for Go is
now available:

Here is a list of changes in this release:

- Comfortable support for MapReduce was implemented.

This trivial example will count the number of occurrences of a
field named n on each document in a collection, and will
return results inline:

job := mgo.MapReduce{
Map: "function() { emit(this.n, 1) }",
Reduce: "function(key, values) { return Array.sum(values) }",
var result []struct { Id int "_id"; Value int }
_, err := collection.Find(nil).MapReduce(job, &result)
if err != nil {
for _, item := range result {

For more details, check the documentation:

- New Distinct method for querying collections for distinct values:

- After feedback and debate in the mailing list, gobson will again
marshal (u)int64 values as int64 MongoDB values, even if they
would fit in an int32 value for storage. But then:

- gobson now supports a "/s" suffix in struct fields, and will
conditionally marshal int64 values in these fields in the
shortest possible space.

- New gobson Raw.Unmarshal function for unmarshalling individual
elements of a document lazily and conditionally:

Gustavo Niemeyer

Reply all
Reply to author
0 new messages