Skip to content
This repository
Browse code

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

  • Loading branch information...
commit 55fa1b7670cff21adb4e398796cbdb4f224347b6 1 parent 7998f56
Jeff Scott Brown jeffbrown authored
34 src/en/ref/Domain Classes/first.gdoc
... ... @@ -0,0 +1,34 @@
  1 +h1. first
  2 +
  3 +h2. Purpose
  4 +
  5 +Retrieves the first instance of the domain class.
  6 +
  7 +h2. Examples
  8 +
  9 +Given the domain class:
  10 +
  11 +{code:java}
  12 +class Person {
  13 + String firstName
  14 + String lastName
  15 + Integer age
  16 +}
  17 +{code}
  18 +
  19 +{code:java}
  20 +// retrieve the first person ordered by the identifier
  21 +def p = Person.first()
  22 +
  23 +// retrieve the first person ordered by the lastName property
  24 +p = Person.first(sort: 'lastName')
  25 +{code}
  26 +
  27 +Parameters:
  28 +
  29 +* @sort@ (optional) - The name of the property to sort by
  30 +
  31 +See also:
  32 +
  33 +* [last|domainClasses]
  34 +
35 src/en/ref/Domain Classes/last.gdoc
... ... @@ -0,0 +1,35 @@
  1 +h1. last
  2 +
  3 +h2. Purpose
  4 +
  5 +Retrieves the last instance of the domain class.
  6 +
  7 +h2. Examples
  8 +
  9 +Given the domain class:
  10 +
  11 +{code:java}
  12 +class Person {
  13 + String firstName
  14 + String lastName
  15 + Integer age
  16 +}
  17 +{code}
  18 +
  19 +{code:java}
  20 +// retrieve the last person ordered by the identifier
  21 +def p = Person.last()
  22 +
  23 +// retrieve the last person ordered by the lastName property
  24 +p = Person.last(sort: 'lastName')
  25 +{code}
  26 +
  27 +Parameters:
  28 +
  29 +* @sort@ (optional) - The name of the property to sort by
  30 +
  31 +See also:
  32 +
  33 +* [first|domainClasses]
  34 +
  35 +

0 comments on commit 55fa1b7

Please sign in to comment.
Something went wrong with that request. Please try again.