use SystemQueryOptions
to control response size
, element projection
and order
skip
first 30 records and top
10 records
// equal to $format=json&$skip=30&$top=10
OData.newOptions().skip(30).top(10)
filter data by properties value
// $format=json&$filter=A eq 'test'
OData.newOptions().filter(OData.newFilter().property("A").eq("test"))
// same
OData.newOptions().filter().property("A").eq("test")).filterEnd()
// freedom filter
OData.newOptions().filter("A eq 'test'")
response with all records count, usefully.
also could set with filter
, and response with filtered records count.
// equal to $format=json&$inlinecount=allpages
OData.newOptions().inlinecount(true).top(1).select("ObjectID")
sort response data
// result is $format=json&$orderby=CreationDateTime desc
OData.newOptions().orderby("CreationDateTime")
// result is $format=json&$orderby=A desc,B asc
OData.newOptions().orderby([{ field: "A" }, { field: "B", order: "asc" }])
expand association data
// $expand=Customers
OData.newOptions().expand("Customers")
// $expand=Customers,Employees
OData.newOptions().expand(["Customers", "Employees"])
remove unused properties from response
// $format=json&$select=ObjectID,Name
OData.newOptions().select("ObjectID").select("Name");
support aggregations by
$apply
, only applicable for OData v4
// $apply=groupBy((Time),aggregate(Amount with sum as Total))/aggregate(Total with average as DailyAverage)
OData.newOptions().apply(
[
transformation().groupBy(
['Time'],
transformation().aggregate('Amount with sum as Total')
),
transformation().aggregate('Total with average as DailyAverage'),
]
)
search all supported properties with text
SAP systems feature
LOW PERFORMANCE
// fuzzy
// $format=json&$search=%any word%
OData.newOptions().search("any word");
// not fuzzy
// $format=json&$search=any word
OData.newOptions().search("any word", false);
i know some odata system support custom query parameter for key authentication or other usage
OData.newOptions().custom("access_token", "token_value"); // => $format=json&access_token=token_value
OData.newOptions().custom("search", "v1"); // => $format=json&search=v1