Documentation ¶
Index ¶
- Variables
- func AddPostInitProcessor(processor PostInitProcessorFunc)
- func Init()
- type PostInitProcessorFunc
- type SessionHandlerFunc
- type XormController
- func (c *XormController) Attach() revel.Result
- func (c *XormController) AttachSession()
- func (c *XormController) Commit() revel.Result
- func (c *XormController) Detach() revel.Result
- func (c *XormController) DetachSession()
- func (c *XormController) WithNewSession(handler SessionHandlerFunc) error
- func (c *XormController) WithNewTx(handler SessionHandlerFunc) error
- func (c *XormController) WithSession(handler SessionHandlerFunc) error
- func (c *XormController) WithTx(handler SessionHandlerFunc) error
- type XormSessionController
Constants ¶
This section is empty.
Variables ¶
Functions ¶
func AddPostInitProcessor ¶
func AddPostInitProcessor(processor PostInitProcessorFunc)
Add post xorm.Engine init. handler. Common use cases are sync domain models, custom mapper, etc.
Types ¶
type PostInitProcessorFunc ¶
type SessionHandlerFunc ¶
type XormController ¶
XormController to be added as anonymous member to the revel controller struct, with XormController.Engine attached.
type MyXormController struct { *revel.Controller xormmodule.XormController }
func (*XormController) Attach ¶
func (c *XormController) Attach() revel.Result
Attach XormController.Engine, this is automatically done at revel.BEFORE revel.InterceptMethod step.
func (*XormController) AttachSession ¶
func (c *XormController) AttachSession()
Create xorm.Session and attached to XormSession member if not already attached.
func (*XormController) Commit ¶
func (c *XormController) Commit() revel.Result
Commit and Close attached XormSession, this is automatically done at revel.AFTER revel.InterceptMethod step. Issue panic if commit XormSession is undesired.
func (*XormController) Detach ¶
func (c *XormController) Detach() revel.Result
Detach XormController.Engine, this is automatically done at revel.FINALLY revel.InterceptMethod step.
func (*XormController) DetachSession ¶
func (c *XormController) DetachSession()
Detach XormSession member and call xorm.Session.Close() if has attached XormSession.
func (*XormController) WithNewSession ¶
func (c *XormController) WithNewSession(handler SessionHandlerFunc) error
Create a new xorm.Session and call handler, the xorm.Session will be closed after handler called. Where common use cases being required async DB operation in another thread.
func (c MyXormController) List() revel.Result { // async fetch xorm.Session operation go c.WithNewSession(func(s *xorm.Session) { // fetch list from s }) }
func (*XormController) WithNewTx ¶
func (c *XormController) WithNewTx(handler SessionHandlerFunc) error
Begin a SQL transaction and if handler did not return error it will commit the transaction, otherwise rollback the transaction. This will create a new xorm.Session for the handler. Where common use cases being required async DB operation in another thread.
func (*XormController) WithSession ¶
func (c *XormController) WithSession(handler SessionHandlerFunc) error
Attach XormSession and call handler.
func (c MyXormController) List() revel.Result { c.WithSession(func(s *xorm.Session) { // fetch list from s }) }
func (*XormController) WithTx ¶
func (c *XormController) WithTx(handler SessionHandlerFunc) error
Begin a SQL transaction and if handler did not return error it will commit the transaction, otherwise rollback the transaction. This will use attached XormSession if already attached.
type XormSessionController ¶
type XormSessionController struct {
XormController
}
XormSessionController to be added as anonymous member to the revel controller struct, with XormController.Engine and XormController.XormSession attached.
type MyXormSessionController struct { *revel.Controller xormmodule.XormSessionController }
func (*XormSessionController) Attach ¶
func (c *XormSessionController) Attach() revel.Result
Attach XormSessionController.XormSession, this is automatically done at revel.BEFORE revel.InterceptMethod step.