dunn less
dunn less

Reputation: 623

Grails service mongodb

Using mongodb in grails i am trying to get a hold of the database from a service in the same fashion as when connecting to it from a controller.

e.g

static mongo
    def db = mongo.getDB("dbone")

this does not seem to work. Is there a way to get a hold of the database from within a service in some other fasion?

Upvotes: 0

Views: 237

Answers (1)

Graeme Rocher
Graeme Rocher

Reputation: 7985

You're using a 'static' variable which is incorrect. Try 'def mongo'

Upvotes: 2

Related Questions