Permalink
Browse files

* get method extended

* easy access query interface
  • Loading branch information...
Juri Kuehn
Juri Kuehn committed Oct 22, 2011
1 parent aba39d6 commit 9c1cb5bad29c2f67f5871eb2b7db4aaca5a97cd5
View
@@ -2,6 +2,11 @@ h2. Change Log
Also see the "release notes of underlying morphia library":http://code.google.com/p/morphia/wiki/ReleaseNotes and the GORM-MongoDB "User Guide":http://jkuehn.github.com/gorm-mongodb/
+h3. v0.7.5 - 2011-10-23
+* MongoDB authentication configuration (thanks to Dave)
+* "Convenient access to morphias query methods":http://jkuehn.github.com/gorm-mongodb/ref/Domain Classes/query.html
+* Static get() method now also accepts com.mongodb.DBRef and com.google.code.morphia.Key instances
+
h3. v0.7.4 - 2011-10-13
* Grails 2.0 compatibility
* Added validation property to query parameters to optionally turn of validation (thanks to Alexander)
@@ -20,7 +20,7 @@ class MongodbMorphiaGrailsPlugin {
def scm = [ url: "https://github.com/jkuehn/gorm-mongodb" ]
// the plugin version
- def version = "0.7.4"
+ def version = "0.7.5"
// the version or versions of Grails the plugin is designed for
def grailsVersion = "1.3.4 > *"
// the other plugins this plugin depends on
@@ -39,7 +39,7 @@ class MongodbMorphiaGrailsPlugin {
def author = "Juri Kuehn"
def authorEmail = "juri.kuehn at gmail.com"
- def title = "Alternative MongoDB GORM based on the Morphia library (former gorm-mongodb)"
+ def title = "Alternative MongoDB GORM based on the Morphia library"
def description = '''GORM implementation for the MongoDB NoSQL database based on the Morphia library'''
// URL to the plugin's documentation
@@ -118,6 +118,8 @@ class MongodbMorphiaGrailsPlugin {
}
datastore.getByKey(clazz, delegate)
}
+
+ MongoPluginSupport.enhanceMorphiaQueryClass()
}
/**
View
@@ -12,4 +12,4 @@ Special thanks to the contributors:
* Alex Duan
* Alexander Riss
* Hasan Ozgan
-
+* Dave Smith
View
@@ -1,7 +1,7 @@
h1. TODOs / ideas for next releases
+* check code in MongoPluginSupport for changes borrowed from org.codehaus.groovy.grails.plugins.DomainClassGrailsPlugin
* implement "sparse index definitions":http://www.mongodb.org/display/DOCS/Indexes#Indexes-SparseIndexes for MongoDB 1.8
-* Check out Datastore getByKeys(keys) for Key.fetch() - if not working with fetched keys from db (has no kindClass), then raise issue
* write some documentation with examples for referencing and embedding entities
* document TransformationConfiguration annotation and put a page about inheritance in the docs
* document merge() instance method
View
@@ -1,8 +1,8 @@
#Grails Metadata file
-#Thu Oct 13 18:24:25 CEST 2011
-app.grails.version=2.0.0.M2
+#Sat Oct 22 14:08:52 CEST 2011
+app.grails.version=2.0.0.RC1
app.name=mongodb-morphia
-app.version=0.7.4
-plugins.hibernate=2.0.0.M2
+app.version=0.7.5
+plugins.hibernate=2.0.0.RC1
plugins.release=1.0.0.RC3
-plugins.tomcat=2.0.0.M2
+plugins.tomcat=2.0.0.RC1
@@ -4,7 +4,7 @@ mongodb {
if (currentHost == 'rem-juri') {
replicaSet = [ "localhost:27017"]
} else if (System.getProperty('user.name').toLowerCase() == 'juri') {
- replicaSet = [ "192.168.1.101:27017"]
+ replicaSet = [ "192.168.1.100:27017"]
} else {
replicaSet = [ "localhost:27017"]
}
@@ -9,9 +9,9 @@ Features implemented to far:
* Constraints and validation support
* Automatic timestamping of dateCreated and lastUpdated
* Gorm events beforeSave, afterSave, beforeDelete, afterDelete, beforeValidate (others, like afterLoad are supported by "Morphia":http://code.google.com/p/morphia/wiki/LifecycleMethods )
-* Works with MongoDB 1.6 and 1.8
+* Works with MongoDB 1.6, 1.8 and 2.0
* AST Transformations that inject all necessary fields and annotations for morphia
-* Lazy references supported
+* Lazy references supported (experimental)
* generate-all support
This plugin is not feature complete concerning the GORM api. Yet it has been proven to be very stable in our production environment. See the "quickstart":2.%20Quickstart.html page for a usage example. You can also download a "petclinic sample application port":https://github.com/jkuehn/gorm-mongodb which uses mongodb-morphia to see the use of embedded and referenced domain classes.
@@ -14,5 +14,5 @@ h2. Description
Parameters:
-* @id@ - The id of the object to retrieve
+* @id@ - The id of the object to retrieve. Alternatively, you can pass a "com.mongodb.DBRef":http://api.mongodb.org/java/current/com/mongodb/DBRef.html or a "com.google.code.morphia.Key":http://morphia.googlecode.com/svn/site/morphia/apidocs/com/google/code/morphia/Key.html object.
@@ -0,0 +1,58 @@
+h1. query
+
+h2. Purpose
+
+Finds all of the domain class instances using morphias "query":http://morphia.googlecode.com/svn/site/morphia/apidocs/com/google/code/morphia/query/QueryImpl.html
+
+h2. Examples
+
+{code:java}
+// get a query instance for Book class
+def query = Book.query()
+
+// get a query instance for Book class, precofigured with pagination params
+def query = Book.query(params)
+
+// pass a closure that will be executed in query context
+def query = Book.query([sort: "releaseDate", order: "desc"]) {
+ field('author').equal("Steven King")
+ field('title').startsWith("The")
+}
+
+// pass a closure only
+def query = Book.query() {
+ field('author').equal("Steven King")
+ field('title').startsWith("The")
+ offset(10)
+}.asList()
+
+// work with query object
+def query = Book.query()
+query.field('author').equal("Steven King")
+query.field('title').startsWith("The")
+query.offset(10)
+
+
+// Query interface provides many methods for returning the results
+query.asList() // return matched results as List
+query.get() // return first result
+for (Book book in query) { ... } // query implements the Iterable interface
+
+{code}
+
+h2. Description
+
+{code:java}
+Book.query( )
+Book.query( Map params )
+Book.query( Map params, Closure config )
+{code}
+
+Parameters:
+
+* @params@ - A Map containing parameters @max@, @offset@, @sort@, @order@ and @validation@ (to turn off morphia mapping validation)
+* @config@ - A closure that will be executed in context of Query
+
+Returns:
+
+Instance of a "QueryImpl":http://morphia.googlecode.com/svn/site/morphia/apidocs/com/google/code/morphia/query/QueryImpl.html
Oops, something went wrong.

0 comments on commit 9c1cb5b

Please sign in to comment.