Skip to content
Guido Barbaglia edited this page May 27, 2015 · 5 revisions

The service can be consumed through a GET call to WDS.

Payload

SQL and OrientDB

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"
}

MongoDB

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
}

Output

The output can be an array of objects or an array of arrays, according to the value of the outputType parameter.

Full Example

$.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);
   }

});
Clone this wiki locally