Search code examples
mongodbgrailsgrails-orm

How to map Grails domain object to a specific mongodb table name


I've setup a simple grails app looking at a mongodb.

My domain object looks like this:

class GoogleSearch {
    String _id;
    String id;
    String query;
    String site;
    Object results;
    Date date;

    static mapping = {
        table 'google_searches'
    }

    static constraints = {
    }
}

However when I run the grails app up, it keeps reading/writing to a table named "googleSearch"

Does anyone know how I can override this default naming? Is it a gorm/mongodb thing?

Cheers


Solution

  • Basics of MongoDB. There is no concept of table. It is always collections. :)
    Refer mapping as collection 'google_searches'.

    For more details you can refer Grails MongoDB plugin.