Following the release r59 of Go, another quick update on the
mgo MongoDB driver for Go is available, including compatibility
fixes and a few additional goods.
The project page with details is available at:
http://labix.org/mgo
The following changes were made in release r2011.08.02.
- The tag format for marshalled fields has been changed to
follow the conventions established in release r59 of Go.
The key name within the tag is now separated from flags
using a comma, and flags have also been renamed.
Here is a simple table for migration:
"/c" => ",omitempty"
"/s" => ",minsize"
"/cs" => ",omitempty,minsize"
"key" => "key"
"key/c" => "key,omitempty"
"key/s" => "key,minsize"
"key/cs" => "key,omitempty,minsize"
If provided with an old-styled tag, gobson will panic
reporting the problem and will also inform the new
spelling for the specific tag at hand.
For more details, please see the documentation:
http://goneat.org/lp/gobson/bson#Marshal
http://goneat.org/lp/gobson/bson#Unmarshal
- The bson tag information can now be namespaced. For
example, the following is a valid tag with information for
both the json and the bson packages:
`bson:",omitempty" json:",omitempty"`
Using the bson namespace is optional as long as the
content of the tag, which should be fully oriented towards
gobson, does not contain the ":" character.
- To improve consistency in the naming convention, the recently
introduced GetRef methods have been renamed to FindRef, and
GetLiveServers was renamed to LiveServers:
http://goneat.org/lp/mgo#Session.FindRef
http://goneat.org/lp/mgo#Database.FindRef
http://goneat.org/lp/mgo#Session.LiveServers
- New ObjectId.Hex method to obtain the commonly wanted hex
representation of the id, as requested by Travis Reeder:
http://goneat.org/lp/gobson/bson#ObjectId.Hex
- ObjectId pointers may now be marshalled and unmarshalled
properly by the json package, also requested by Travis:
http://goneat.org/lp/gobson/bson#ObjectId.MarshalJSON
http://goneat.org/lp/gobson/bson#ObjectId.UnmarshalJSON
- New DatabaseNames and CollectionNames methods, as requested
by Fabian Reinartz:
http://goneat.org/lp/mgo#Session.DatabaseNames
http://goneat.org/lp/mgo#Database.CollectionNames
- New GridFile.UploadDate method, also requested by Fabian:
http://goneat.org/lp/mgo#GridFile.UploadDate
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog
-- I never filed a patent.