Just tagged a release of the mgo MongoDB driver for Go
with some minor updates.
Project details are available at:
The following changes were made in this release:
- Fields using a `bson:"-"` tag are now ignored.
Thanks to Aaron Raddon for pointing out the missing
feature.
- Implemented unmarshaling of BSON lists onto Go arrays.
For an array to be successfully unmarshalled, it must
match exactly the size of the BSON list. Problem
reported by John Asmuth.
- The stock url.URL type is now marshalled and unmarshalled
by the bson package as a string.
- Clarified documentation for EnsureIndex to make it clear
that MongoDB does NOT return immediately even if Background
is set to true. The setting affects the ability of other
sessions and connections to use the given collection while
the index is being built.
--
Gustavo Niemeyer
http://niemeyer.net
http://niemeyer.net/plus
http://niemeyer.net/twitter
http://niemeyer.net/blog
-- I'm not absolutely sure of anything.
On Sun, Mar 4, 2012 at 12:42, Paddy Foran <foran...@gmail.com> wrote:
> Thanks for the new release!
You're very welcome.
> Is there any way to make the url.URL type continue to marshal/unmarshal as a
> struct? I actually preferred having it split into its component parts.
It surprises me a bit that you find marshaling raw URLs convenient.
Note that something like "http://example.com" will be stored in the
database as:
{"scheme": "http", "host": "example.com", "path": "", "user": nil,
"opaque": false, "rawquery": "", "fragment": ""}
Besides the fact that this feels a bit inconvenient both for querying
and in terms of the disproportional storage space required for it, the
"user" field will never marshal correctly, which is why I felt
comfortable with the change.
In case you do want to marshal the individual fields, I suggest
creating a type based on URL that has a custom GetBSON method.
Does that sound ok or is it too much of a hassle?
> Is there any way to make the url.URL type continue to marshal/unmarshal as a> struct? I actually preferred having it split into its component parts.It surprises me a bit that you find marshaling raw URLs convenient.
Note that something like "http://example.com" will be stored in the
database as:
{"scheme": "http", "host": "example.com", "path": "", "user": nil,
"opaque": false, "rawquery": "", "fragment": ""}
Besides the fact that this feels a bit inconvenient both for querying
and in terms of the disproportional storage space required for it, the
"user" field will never marshal correctly, which is why I felt
comfortable with the change.
In case you do want to marshal the individual fields, I suggest
creating a type based on URL that has a custom GetBSON method.
Does that sound ok or is it too much of a hassle?
If you need fast queries by path, it may justify storing it in an
expanded form, otherwise you won't benefit from indexing. For scheme
and host (given a reduced set of schemes), you can do that efficiently
with a single field.