Anonymous Human
Anonymous Human

Reputation: 1948

Grails Mongodb static collections access

I have a Grails application that uses Mongodb to persist domain classes. I also have some collections in Mongodb that aren't modeled after my domain classes because they are just static data like telephone codes and currency exchange rates. How do I go about accessing these collections via my code since they aren't modeled after domain classes, I cannot use GORM's finders to retrieve these data correct?

Upvotes: 0

Views: 65

Answers (2)

Swapnil Sawant
Swapnil Sawant

Reputation: 620

GORM is not an option. Add mongo java driver dependency in buildConfig.groovy like
runtime 'org.mongodb:mongo-java-driver:2.11.3', refresh your dependencies and then follow this answer of mine which shows how to access such collections from mongodb which is not modelled after domain classes.

Upvotes: 1

Markus W Mahlberg
Markus W Mahlberg

Reputation: 20712

The Gorm Plugin offers access to the low level API. Have a look at http://grails.github.io/grails-data-mapping/mongodb/manual/guide/4.%20Low-level%20API.html

Upvotes: 0

Related Questions