Is it possible to use mgo driver to execute mongodb functions during an update or insert while using a struct object?
err := db.C(collectionName).UpdateId(eventID, Event{
Name: eventName,
Club: getClubName(clubID), //how to call mongodb getClubName function?
})
I have a mongodb function that returns a club name when given a club id. The following executes OK in the mongodb shell.
db.loadServerScripts();
db.Event.update({"_id" : "30fc..."}, {"name": "foo_bar" , "clubName": getClubName("4df32...")});
I can execute an additional database lookup to get the club name, but would prefer this to be atomic if possible.