Announcing mgo r2011.04.19

Skip to first unread message

Gustavo Niemeyer

Apr 19, 2011, 8:48:04 PM4/19/11
to golang-nuts,,
The r2011.04.19 release of the mgo MongoDB driver for Go is out.
This is an interim release with several minor improvements and a
few incompatible changes towards the next major feature release
which is still in the works.

Here is a list of changes in this release:

- HEADS UP: The gobson Milliseconds type was removed, and
a new Timestamp type introduced. The new type will decode
date values as NANOSECONDS rather than milliseconds. This
change was done to better match common Go idioms.

If you are using Milliseconds, do not simply rename the type
in your code or it will yield bugs. Also note that this is
a Go-only change, which doesn't affect the stored data in
any regard (the same marshalled content will be sent
in the wire as the previous release).

- A much simpler iteration mechanism was introduced via
Query.For and Iter.For. An example follows:

var result *struct{ N int }
err := query.For(&result, func() os.Error {
// Use result.

See the documentation for more details:

- A few methods were renamed to establish a more consistent
naming convention:

collection.GetIndexes() => collection.Indexes()
session.GetMode() => session.Mode()
session.Unsafe() => session.SetSafe(nil)
session.Safe(0, 0, false) => session.SetSafe(&mgo.Safe{})
session.Safe(1, 0, false) => session.SetSafe(&mgo.Safe{W: 1})
session.Batch(n) => session.SetBatch(n)
session.Prefetch(f) => session.SetPrefetch(f)

- New Safe method for reading current safety parameters:

- New EnsureSafe method for ensuring at least the given safety
level guarantees are in place. More details at:

- More clear panics when using closed sessions improperly.

- gobson now delivers int64 values as int32 for storage in case
the value fits. This should have a positive impact on the
space used for document storage without imposing any extra
burden, since gobson correctly decodes int values across
different types.

- gobson got a new Raw type to enable more advanced use cases:

Gustavo Niemeyer

Reply all
Reply to author
0 new messages