Skip to content

PatrickWolleb/revmgo

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

58 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

revmgo Build Status

mgo module for revel framework

This is a mantained fork of https://github.com/jgraham909/revmgo.

Installation

    go get github.com/janekolszak/revmgo

Test

    revel test github.com/janekolszak/revmgo/testapp dev

Configuration

In app.conf:

Initialization

  • In app.init() in app/init.go add:
    revel.OnAppStart(revmgo.AppInit)
  • In controllers.init() in app/controllers/init.go add
    revmgo.ControllerInit()

So a minimal controller's init() would be:

    package controllers

    import "github.com/janekolszak/revmgo"

    func init() {
        revmgo.ControllerInit()
    }

Usage

Embed the MongoController on your custom controller;

    package controllers

    import (
        "github.com/janekolszak/revmgo"
        "github.com/revel/revel"
    )

    type App struct {
        *revel.Controller
        revmgo.MongoController
  		// ...
  	}

The controller will now have a MongoSession variable of type *mgo.Session. Use this to query your mongo datastore.

Use revmgo in revel.jobs

    package controllers

    import (
        "github.com/janekolszak/revmgo"
        "github.com/revel/revel"
    )

    type Job struct {}
    func(j Job){
        s, err := revmgo.GetSession()
        if err != nil {
            // error
        }
        defer s.Close()
        // ...
    }

See Also

About

mgo module for revel framework - maintained fork from jgraham909/revmgo

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Go 95.7%
  • HTML 4.3%