• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: Fetchspec of average related field
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Fetchspec of average related field


  • Subject: Re: Fetchspec of average related field
  • From: Lachlan Deck <email@hidden>
  • Date: Tue, 8 May 2007 06:48:07 +1000

On 07/05/2007, at 10:20 PM, Drew Thoeni wrote:

I have two objects: Item and a to-many child, review.

Review has an attribute called rating.

I'm trying to use a fetchspec (which appears to be an impossibility) that returns the top 10 reviewed items. Basically, I'd like to sort by email@hiddeng and have only 10 items returned.

I'm not sure why you need @avg actually...

public NSArray topTenReviews() {
	EOQualifier qualifier;
	NSArray sortOrderings;
	EOFetchSpecification fetchSpec;

qualifier = new EOKeyValueQualifier( "item", EOQualifier.QualifierOperatorEqual, this );
sortOrderings = new NSArray( EOSortOrdering.sortOrderingWithKey ( "rating", EOSortOrdering.CompareAscending ) );
fetchSpec = new EOFetchSpecification( "Review", qualifier, sortOrderings );
fs.setFetchLimit( 10 );


	return ec.objectsWithFetchSpecification( fs );
}

This can be defined in the model as a fetchspec if you prefer.

If you do need @avg then do what John Huss suggested (and substite "rating" above for "item.avgRating").

with regards,
--

Lachlan Deck



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >Fetchspec of average related field (From: Drew Thoeni <email@hidden>)

  • Prev by Date: Re: WOPopup will not give value to DB
  • Next by Date: Re: Adding/Removing objects to/from toMany relationships.
  • Previous by thread: Re: Fetchspec of average related field
  • Next by thread: WOPopup will not give value to DB
  • Index(es):
    • Date
    • Thread