Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( Session *mgo.Session // Global mgo Session Dial string // http://godoc.org/labix.org/v2/mgo#Dial Method string // clone, copy, new http://godoc.org/labix.org/v2/mgo#Session.New )
View Source
var ObjectIdBinder = revel.Binder{ Bind: revel.ValueBinder(func(val string, typ reflect.Type) reflect.Value { if len(val) == 0 { return reflect.Zero(typ) } if bson.IsObjectIdHex(val) { objId := bson.ObjectIdHex(val) return reflect.ValueOf(objId) } else { glog.Error("ObjectIdBinder.Bind - invalid ObjectId!") return reflect.Zero(typ) } }), Unbind: func(output map[string]string, name string, val interface{}) { var hexStr string hexStr = fmt.Sprintf("%s", val.(bson.ObjectId).Hex()) if bson.IsObjectIdHex(hexStr) { output[name] = hexStr } else { glog.Error("ObjectIdBinder.Unbind - invalid ObjectId!") output[name] = "" } }, }
Custom TypeBinder for bson.ObjectId Makes additional Id parameters in actions obsolete
Functions ¶
func ControllerInit ¶
func ControllerInit()
func MethodError ¶
Types ¶
type MongoController ¶
type MongoController struct { *revel.Controller MongoSession *mgo.Session // named MongoSession to avoid collision with revel.Session }
func (*MongoController) Begin ¶
func (c *MongoController) Begin() revel.Result
Connect to mgo if we haven't already and return a copy/new/clone of the session
func (*MongoController) End ¶
func (c *MongoController) End() revel.Result
Close the controller session if we have an active one.
Click to show internal directories.
Click to hide internal directories.