[ANN] mgo r2011.05.24, with atomic improvements

37 views
Skip to first unread message

Gustavo Niemeyer

unread,
May 23, 2011, 11:33:11 PM5/23/11
to golang-nuts, mongod...@googlegroups.com, mgo-...@googlegroups.com
The r2011.05.24 release of the mgo MongoDB driver for Go is now
available, with some neat improvements in the area of atomic
updates:

http://labix.org/mgo

More specifically, the following changes were performed in this
release:

- Way to pronounce the project name defined! ;-) It's pronounced
as _mango_ (not mmmmgo, not em-go).

- The FindAndModify command was integrated into the Query
type, via the Modify method. This example, for instance, sets N to
42 and returns its previous value:

change := mgo.Change{Update: M{"n": 42}}
err = col.Find(M{"_id": id}).Modify(change, &doc)
fmt.Println(doc.N)

More details may be found in the documentation:

http://goneat.org/lp/mgo#Query.Modify

- Update and UpdateAll will now return mgo.NotFound when no
documents are updated. See the documentation for details:

http://goneat.org/lp/mgo#Collection.Update
http://goneat.org/lp/mgo#Collection.UpdateAll

- Upsert now returns the inserted id when the document is
not found for updating:

http://goneat.org/lp/mgo#Collection.Upsert


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

Reply all
Reply to author
Forward
0 new messages