Skip to content

Commit

Permalink
Merge pull request #10 from drewwells/inittest
Browse files Browse the repository at this point in the history
Add example pulling key values from revmgo on init
  • Loading branch information
jgraham909 committed Jun 4, 2014
2 parents aae7f31 + f7132be commit f49c6d0
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions testapp/app/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,4 +20,26 @@ func init() {
revel.InterceptorFilter, // Run interceptors around the action.
revel.ActionInvoker, // Invoke the action.
}

revel.OnAppStart(func() {

keyValues := []map[string]string{}

db := revmgo.Session.DB("test")
col := db.C("config")
query := col.Find(nil)

err := query.All(&keyValues)

if err != nil {
revel.ERROR.Printf("%v", err)
} else if keyValues != nil {
for key, value := range keyValues {
revel.INFO.Printf("%s: %s", key, value)
}
} else {
revel.INFO.Printf("No keys found")
}

})
}

0 comments on commit f49c6d0

Please sign in to comment.