Print Page | Close Window

Query using Take

Printed From: IdeaBlade
Category: Breeze
Forum Name: Community Forum
Forum Discription: Build rich JavaScript apps using techniques you already know
Printed Date: 28-Feb-2020 at 12:09pm

Topic: Query using Take
Posted By: Orizz
Subject: Query using Take
Date Posted: 26-Oct-2012 at 4:28am
Hi there,

Working my way through Breeze and very impressed so far.

I was wondering if its possible to use a combination of Take / Expand in a query for example...

var query = new entityModel.EntityQuery()
                 .from("Customers").where("CustId", "==", "1").expand("Orders").take(500);

var query = new entityModel.EntityQuery()
                 .from("Customers").where("CustId", "==", "1").select().expand("Orders").take(500);

var query = new entityModel.EntityQuery()
                 .from("Customers").where("CustId", "==", "1").take(1).expand("Orders").take(500);

I've tried a combination of the above without any luck, I just want a top level Customer object and a list of limited Orders

Hope you can help!

Posted By: jtraband
Date Posted: 26-Oct-2012 at 5:41pm
Unfortunately no.  Expand will simply expand whatever the rest of the query returns


var query = new entityModel.EntityQuery()
                 .where("CustId", "==", "1")

will give you cust: 1 and all of its orders; we do not yet have a good way to say "give me cust: 1 and just its first 500 orders.

What we have looked at, but is still in the research stage is the ability to do subqueries in projections, so that you could potentially, ( meaning not yet), do the following.

var query = new entityModel.EntityQuery()
                 .where("CustId", "==", "1")
                 .select("customerName, orders.take(500)");

Note that projections work today, but they cannot currently contain query clauses.

If this looks useful, please vote for this feature using the feedback mechanism on the web site. ( small icon on the right side of any Breeze website page labeled "Feedback").  This helps us decide which features to focus on next.

Print Page | Close Window