-
Notifications
You must be signed in to change notification settings - Fork 2
3.2) Retrieve
Guido Barbaglia edited this page May 27, 2015
·
5 revisions
The service can be consumed through a GET
call to WDS.
The payload consists of an object containing the query
field that is populated with the SQL query to be sent to the database.
{
"query": "SELECT AreaCode, AreaNameE FROM Area"
}
The payload is more complex and requires four parameters:
Name | Description |
---|---|
query | The document that represents the query. |
filters | The dimensions to be shown in the output. |
sort | The sorting order for each dimension. |
limit | The number of records to be retrieved. |
{
"query": {
"state": "MA"
},
"filters": {
"city": 1,
"pop": 1
},
"sort": {
"pop": -1
},
"limit": 0
}
The output can be an array of objects or an array of arrays, according to the value of the outputType
parameter.
$.ajax({
type: 'GET',
url: 'rest/crud',
data: {
payload: {
"query": {
"state": "MA"
},
"filters": {
"city": 1,
"pop": 1
},
"sort": {
"pop": -1
},
"limit": 0
},
datasource: "my_datasource",
collection: "my_collection",
outputType: "object"
},
success: function (response) {
/* Do something with the output... */
},
error: function (a) {
alert(a.responseText);
}
});