Skip to content

Instantly share code, notes, and snippets.

@tyama
Created July 12, 2013 07:35
Show Gist options
  • Save tyama/5982605 to your computer and use it in GitHub Desktop.
Save tyama/5982605 to your computer and use it in GitHub Desktop.
using gorm-mongo in Ratpack
import com.google.inject.AbstractModule
import static org.ratpackframework.groovy.RatpackScript.ratpack
import org.grails.datastore.gorm.mongo.config.*
import domains.*
ratpack {
modules {
register(new AbstractModule() {
protected void configure() {
MongoDatastoreConfigurer.configure("myDatabase", Book)
}
})
}
handlers {
get('mongo'){
response.send "Hello"
Book.withSession {
new Book(title:"The Stand").save(flush:true)
Book.list().each {
println it.title
}
}
}
assets "public"
}
}
//ドメインは
package domains
import grails.persistence.*
@Entity
class Book {
String title
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment