Permalink
Browse files

GRAILS-8821 - docs for first() and last() methods

  • Loading branch information...
1 parent 7998f56 commit 55fa1b7670cff21adb4e398796cbdb4f224347b6 @jeffbrown jeffbrown committed Sep 6, 2012
Showing with 69 additions and 0 deletions.
  1. +34 −0 src/en/ref/Domain Classes/first.gdoc
  2. +35 −0 src/en/ref/Domain Classes/last.gdoc
@@ -0,0 +1,34 @@
+h1. first
+
+h2. Purpose
+
+Retrieves the first instance of the domain class.
+
+h2. Examples
+
+Given the domain class:
+
+{code:java}
+class Person {
+ String firstName
+ String lastName
+ Integer age
+}
+{code}
+
+{code:java}
+// retrieve the first person ordered by the identifier
+def p = Person.first()
+
+// retrieve the first person ordered by the lastName property
+p = Person.first(sort: 'lastName')
+{code}
+
+Parameters:
+
+* @sort@ (optional) - The name of the property to sort by
+
+See also:
+
+* [last|domainClasses]
+
@@ -0,0 +1,35 @@
+h1. last
+
+h2. Purpose
+
+Retrieves the last instance of the domain class.
+
+h2. Examples
+
+Given the domain class:
+
+{code:java}
+class Person {
+ String firstName
+ String lastName
+ Integer age
+}
+{code}
+
+{code:java}
+// retrieve the last person ordered by the identifier
+def p = Person.last()
+
+// retrieve the last person ordered by the lastName property
+p = Person.last(sort: 'lastName')
+{code}
+
+Parameters:
+
+* @sort@ (optional) - The name of the property to sort by
+
+See also:
+
+* [first|domainClasses]
+
+

0 comments on commit 55fa1b7

Please sign in to comment.