diegomvh / angular-odata

Client side OData typescript library for Angular
https://www.npmjs.com/package/angular-odata
MIT License
50 stars 14 forks source link

how to /(S(juqvmnem2qpijynyewk4pld5))/People('russellwhyte')?$expand=Trips($top=2;$skip=1) #65

Closed vigouredelaruse closed 2 years ago

vigouredelaruse commented 2 years ago

i have an $expand query with multiple join clauses and i'd like to page through the expanded terms

my code is shaped as per below, and i'd like to be able to achieve the kind of query as per TripPinRESTierService/(S(juqvmnem2qpijynyewk4pld5))/People('russellwhyte')?$expand=Trips($top=2;$skip=1)

image

please advise

diegomvh commented 2 years ago

Hi @vigouredelaruse Currently the library presents two ways of putting together queries. One based on simple object-based syntax inspired by odata-query, and the other using expressions inspired by odata-filter-builder Both libraries are referenced for more help on how to do queries. Likewise, the library extends these functions looking for a homogeneous behavior to perform everything that refers to queries, that is: I can use both styles of queries in all the functions that OData has (expand, filter, orderBy, select, etc)

The choice of one or the other is a matter of legibility.

I see that you use both in this query. For the use of the expand in the form of an object, what you have to do in each internal object of the expand is to configure that expand with another object :) just need to add skip and top.

tenantEntities.query((q) => {
  //"About tastes there is nothing written", my grandfather used to say
  //This way is clearer for me the orderBy :) 
  q.orderBy([['CreatedAt', 'asc']]);
  q.expand({
    AccessControlEntries: { top: 10, skip: 10 },
    Owners: {},
    Accounts: {}
  });
  q.skip(offset);
  q.top(rowCount);
}

I leave some links to the spec where there are some simple but working examples of queries

Object syntax

Expressions

best regards

vigouredelaruse commented 2 years ago

that looks very straightforward, i will apply the pattern. thanks for the links and the code and 'la sabiduria de tu abuelo'

best regards