Created
July 12, 2013 07:35
-
-
Save tyama/5982605 to your computer and use it in GitHub Desktop.
using gorm-mongo in Ratpack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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