Getting an object or a list of objects: GET method

Getting an object

Obtaining an object is performed using the GETmethod, and the code of the namespace class and the value of the object key are specified, for example``rest/crud/class_string@develop-and-test/66dbb3d0-5583-11e6-aef7-cf50314f026b``

curl -X GET -u demo@local:ion-demo https://dnt.iondv.com/rest/crud/class_string@develop-and-test/66dbb3d0-5583-11e6-aef7-cf50314f026b

An example of a request to the crud service to get an object in dnt: test/modules/rest/crud.spec.js

/Checking crud service/GET/# getting an object (GET)

In addition, the _eager parameter that contains a list of class properties separated by the ` |` symbol for which data must be eagerly loaded (links or collections) can be set in query . For example

curl -X GET -u demo@local:ion-demo https://dnt.iondv.com/rest/crud/class_string@develop-and-test/66dbb3d0-5583-11e6-aef7-cf50314f026b?_eager=string_text

An example of a request to the crud service to get an object with eager loading of the “table” property in dnt: test/modules/rest/crud.spec.js

/Checking crud service/GET/# getting an object with eager loading of the "table" property (GET)

If the object exists, the response code 200 and the object itself in json format are returned, if the object was not found - 404, if there are no rights - 403.

{
    "_id": "66dbb3d0-5583-11e6-aef7-cf50314f026b",
    "__string": "Example of the \"String [0]\" type in the \"Text [1]\" view",
    "__class": "class_string@develop-and-test",
    "__classTitle": "Class \"String [0]\"",
    "id": "66dbb3d0-5583-11e6-aef7-cf50314f026b",
    "string_text": "Example of the \"String [0]\" type in the \"Text [1]\" view",
    "string_miltilinetext": "Example of the \"String [0]\"\r\n in the Multiline text [7] view",
    "string_formattext": "Example of the \r\n \"String [0]\" type \r\n in the \r\nFormatted text [7] view"
}

Getting a list of objects

The list of objects is requested using the GETmethod, and the class code and namespace are specified, for example, rest/crud/class_string@develop-and-test/

curl -X GET -u demo@local:ion-demo https://dnt.iondv.com/rest/crud/class_string@develop-and-test/

An example of a request to the crud service to get a list of objects in dnt: test/modules/rest/crud.spec.js

/Checking crud service/GET/# getting a list of text objects

In response, the service issues a JSON Object with an offset of 0 and a count of 5 records and a status of 200 , if there is no such class, it shows the code 404.

[{"_creator":"admin@local",
"_id":"4567a830-b8ea-11e9-9cdf-7bd384cbb7a5",
"__string":"example1",
"__class":"class_string@develop-and-test",
"__classTitle":"Class \"String [0]\"",
"id":"4567a830-b8ea-11e9-9cdf-7bd384cbb7a5",
"string_text":"example1",
"string_miltilinetext":"example1",
"string_formattext":"<p>example1</p>"},
{"_id":"66dbb3d0-5583-11e6-aef7-cf50314f026b",
"__string":"Example of the \"String [0]\" type in the \"Text [1]\" view",
"__class":"class_string@develop-and-test",
"__classTitle":"Class \"String [0]\"",
"id":"66dbb3d0-5583-11e6-aef7-cf50314f026b",
"string_text":"Example of the \"String [0]\" type in the \"Text [1]\" view",
"string_miltilinetext":"Example of the \"String [0]\"\r\n in the Multiline text [7] view",
"string_formattext":"Example of the \r\n \"String [0]\" type \r\n in the \r\nFormatted text [7] view"}]

The query can be implemented with the following query parameters:

  • _offset - sampling offset, 0 by default
  • _count - number of values in the sample, by default 5
  • _eager - a list of class properties separated by the | symbol for which data must be eagerly loaded.
  • [name of property] - all parameters are assumed to be query names, except those beginning with ``_``which are considered class attribute names, and their values are set as filters.

Examples:

  1. Request for a list of class objects with offset 1 and count 2

    curl -X GET -u demo@local:ion-demo https://dnt.iondv.com/rest/crud/class_string@develop-and-test/?_offset=1&_count=2
    
  2. Request for a list of objects whose string_text property is set to example1

    curl -X GET -u demo@local:ion-demo https://dnt.iondv.com/rest/crud/class_string@develop-and-test/?string_text=example1
    
  3. Request for a list of objects for which the string_text property has the value example1, with an offset of 1 and a count of 2

    curl -X GET -u demo@local:ion-demo https://dnt.iondv.com/rest/crud/class_string@develop-and-test/?string_text=example1&_offset=1&_count=2
    

An example of a request to the crud service to get a list of objects with different shift and filter parameters in dnt: test/modules/rest/crud.spec.js

/Checking crud service/GET/# getting a list of text objects, with an offset of 1 and a count of 2
/Checking crud service/GET/# getting a list of text objects containing a specific string