Announcing mgo r2011.04.19

28 views
Skip to first unread message

Gustavo Niemeyer

unread,
Apr 19, 2011, 8:48:04 PM4/19/11
to golang-nuts, mongod...@googlegroups.com, mgo-...@googlegroups.com
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.

http://labix.org/mgo

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:

http://goneat.org/lp/mgo#Query.For
http://goneat.org/lp/mgo#Iter.For

- 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:

http://goneat.org/lp/mgo#Session.Safe

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

http://goneat.org/lp/mgo#Session.EnsureSafe

- 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:

http://goneat.org/lp/gobson/bson#Raw

--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/blog
http://niemeyer.net/twitter

Reply all
Reply to author
Forward
0 new messages