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 {
panic(err)
}
for _, item := range result {
fmt.Println(item.Value)
}
For more details, check the documentation:
http://goneat.org/lp/mgo#Query.MapReduce
http://goneat.org/lp/mgo#MapReduce
http://goneat.org/lp/mgo#MapReduceInfo
- New Distinct method for querying collections for distinct values:
http://goneat.org/lp/mgo#Query.Distinct
- 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:
http://goneat.org/lp/gobson/bson#Raw.Unmarshal
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/blog
http://niemeyer.net/twitter