janhommes / o.js

o.js - client side oData lib.
https://janhommes.github.io/o.js/example/
MIT License
238 stars 57 forks source link

Need support for $skiptoken and $id system query options #68

Closed be236 closed 5 years ago

be236 commented 6 years ago

For $skiptoken, OData 4.0 spec states:

11.2.5.7 Server-Driven Paging Responses that include only a partial set of the items identified by the request URL MUST contain a link that allows retrieving the next partial set of items. This link is called a next link; its representation is format-specific. The final partial set of items MUST NOT contain a next link. The client can request a maximum page size through the odata.maxpagesize preference. The service may apply this requested page size or implement a page size different than, or in the absence of, this preference. OData clients MUST treat the URL of the next link as opaque, and MUST NOT append system query options to the URL of a next link. Services may not allow a change of format on requests for subsequent pages using the next link. Clients therefore SHOULD request the same format on subsequent page requests using a compatible Accept header. OData services may use the reserved system query option $skiptoken when building next links. Its content is opaque, service-specific, and must only follow the rules for URL query parts. OData clients MUST NOT use the system query option $skiptoken when constructing requests.

And for $id in GET request, it states:

11.2.8 Resolving an Entity-Id To resolve an entity-id, e.g. obtained in an entity reference, into a representation of the identified entity, the client issues a GET request to the $entity resource which located at the URL $entity relative to the service root. The entity-id MUST be specified using the system query option $id. Example 62: return the entity representation for a given entity-id http://host/service/$entity?$id=http://host/service/Products(0) A type segment following the $entity resource casts the resource to the specified type. If the identified entity is not of the specified type, or a type derived from the specified type, the service returns 404 Not Found. After applying a type-cast segment to cast to a specific type, the system query options $select and $expand can be specified in GET requests to the $entity resource. Example 63: return the entity representation for a given entity-id and specify properties to return http://host/service/$entity/Model.Customer? $id=http://host/service/Customers('ALFKI') &$select=CompanyName,ContactName&$expand=Orders

I would like O.js to support these query options. I think there is $id support when DELETing... but not for GET.

janhommes commented 5 years ago

83 removes any specific there. you can use:

o('http://my.endpoint').get('$entity').query({$id:'http://my.endpoint/product/1'})