grails, mongodb - multiple dbs

422 views Asked by At

Is it possible to create aapliaction in grails that works the way: User login with password and login to apliaction (authentication with spring security and postgredb), then aplication geting url to mongodb database (one per user), and then I configre application to use this db (with working mongo maped domain class)

2

There are 2 answers

1
Manish Kapoor On

If I am not wrong, you are asking about possibility of saving data in two data stores(Mongodb and Postgredb). In Postgredb, you want to store Spring Security authentication data and other application data in Mongodb.
Yes, this is possible. My current project had similar requirements and we are using MySQL and MongoDb.

1
Abhishek Tripathi On

Yes you can use Mongo and postgre both using following line of code in dataSource.groovy

development {
    grails {
        mongo {
            host = "localhost"
            username = ""
            password = ""
            databaseName = "schema_name"
        }
    }

    dataSource_lookup {
        dialect = 'org.hibernate.dialect.PostgreSQLDialect'
        pooled = true
        driverClassName = 'org.postgresql.Driver'
        username = "postgres"
        password = "admin"
        dbCreate = "update" // one of 'create', 'create-drop', 'update', 'validate', ''
        url = "jdbc:postgresql://localhost:5432/schama_name?prepareThreshold=5&socketTimeout=5400"
    }
}