From 4a567bc1646557fa9d1dafd990703a651a3c253e Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Tue, 3 Jun 2014 16:14:02 -0500 Subject: [PATCH 1/2] Test of pulling key values from revmgo on init --- testapp/app/init.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/testapp/app/init.go b/testapp/app/init.go index d34d6c8..10925f7 100644 --- a/testapp/app/init.go +++ b/testapp/app/init.go @@ -20,4 +20,26 @@ func init() { revel.InterceptorFilter, // Run interceptors around the action. revel.ActionInvoker, // Invoke the action. } + + revel.OnAppStart(func() { + + var 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") + } + + }) } From f7132be01d5611ee307f335aa84c2877289a5cd7 Mon Sep 17 00:00:00 2001 From: Drew Wells Date: Tue, 3 Jun 2014 16:37:17 -0500 Subject: [PATCH 2/2] instantiate map before using it --- testapp/app/init.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/testapp/app/init.go b/testapp/app/init.go index 10925f7..5de91c5 100644 --- a/testapp/app/init.go +++ b/testapp/app/init.go @@ -23,7 +23,7 @@ func init() { revel.OnAppStart(func() { - var keyValues []map[string]string + keyValues := []map[string]string{} db := revmgo.Session.DB("test") col := db.C("config")