api/db/<dbname>/classes/<struct_no>/byindex/<index_no>/list ResourceThe
api/db/<dbname>/classes/<struct_no>/byindex/<index_no>/listresource executes the following operations for HTTPGETandDELETE:
GET: Returns record(s) of the specified class using the index specified byindex_noDELETE: Deletes individual objects, as specified by the query argumentsFor an overview see page eXtremeDB Web Service Resources
GET
The
GETrequest returns record(s) of the specified class using the index specified byindex_no. This endpoint supports the following query parameters:
count: the number of objects to return; default: 1.skip: the number of objects to skip before returning the result; default: 0.max_array: the maximum number of entries in returned arrays; default: 10.max_vector: the maximum number of entries in returned vectors; default: 10.max_seq: the maximum number of entries in returned sequences; default: 10.max_blob: the maximum size of the returned blobs; default: 1024.When this endpoint is invoked, the web service creates a cursor using the
index_noindex, iterates over itskiptimes, and returnscountrecords in a JSON array.The response is a JSON object with two keys,
"header"and"resultset".The header contains the array of field descriptors
"fields". The format of the descriptors is the same as that in the database schema (see page/api/db/<dbname>/schemafor details). The only difference is that structure fields' descriptors are recursively expanded, that is, every structure field descriptor will also include the array of that structure's fields' descriptors.The result set is an array of JSON objects representing database records. The eXtremeDB record field values are encoded as JSON values using the following rules:
- Scalar values: JSON numerics
- Date and time values: timestamps as JSON numerics
- Boolean values: JSON literals (
true,false)- ASCII strings: JSON strings
- 2-byte and wide character strings: JSON hex-encoded strings (e.g.
"7400650073007400"for string"test"when encoded using theUTF-16-LEencoding)- Fixed- and variable-size binary fields: JSON hex-encoded strings
- Blobs: JSON hex-encoded strings
- Arrays, vectors and sequences: JSON arrays
- Structures: JSON objects
Furthermore,
string,binary,blob,array,vector, andsequencevalues are sent inside JSON objects containing two fields:"len"and"val". The"val"field contains the value encoded as described above. The"len"field specifies the size of the value in the database. This is done to provide actual field size when the value is truncated for some reason, e.g. if limited by themax_array/max_vector/... threshold, or due to memory constraints. The interpretation of the"len"field depends on the data type:
- Strings (ASCII, 2-byte and wide characters): size of the string in bytes (not characters).
- Binary values: size of the value in bytes.
- Blobs: size of the blob in bytes.
- Arrays, vectors, and sequences: number of elements in the value.
When the value is transmitted as a hex-encoded string, which is the case for
binaryvalues,blobs, and non-ASCIIstrings,"len"reflects the size of the value, not its hex representation. That is, for a hex-encoded string"0a0b0c0d","len"will be equal to4.For example, consider the following table and its fields:
CREATE TABLE T4(pk INTEGER PRIMARY KEY, str STRING, bin BINARY(3), arr ARRAY(INTEGER), seq SEQUENCE(CHAR(4)), b BOOLEAN);If the table contains the following data:
XSQL>SELECT * FROM T4; pk str bin arr seq b ------------------------------------------------------------ 1 string1 010203 [1, 2, 3, 4] {AAAA, BBB, CC, D} false 2 string2 null null null trueThe data could be retrieved from the web service with the following request:
GET http://localhost:8083/api/db/xsqldb/classes/3/byindex/0/list?count=2The following JSON response would be returned:
{ "header": { "fields": [ { "field_no": 0, "name": "pk", "type": 6, "type_s": "MCO_DD_INT4" }, { "field_no": 1, "name": "str", "type": 16, "type_s": "MCO_DD_STRING", "flags": 64, "flags_s": [ "MCO_DICT_FI_NULLABLE" ] }, { "field_no": 2, "name": "bin", "type": 38, "type_s": "MCO_DD_BINARY", "flags": 64, "flags_s": [ "MCO_DICT_FI_NULLABLE" ], "size": 3 }, { "field_no": 3, "name": "arr", "type": 6, "type_s": "MCO_DD_INT4", "flags": 68, "flags_s": [ "MCO_DICT_FI_VECTOR", "MCO_DICT_FI_NULLABLE" ] }, { "field_no": 4, "name": "seq", "type": 36, "type_s": "MCO_DD_SEQUENCE_CHAR", "flags": 1088, "flags_s": [ "MCO_DICT_FI_NULLABLE", "MCO_DICT_FI_SEQUENCE" ], "size": 4 }, { "field_no": 5, "name": "b", "type": 25, "type_s": "MCO_DD_BOOL", "flags": 64, "flags_s": [ "MCO_DICT_FI_NULLABLE" ] } ] }, "resultset": [ [ 1, { "len": 7, "val": "string1" }, { "len": 3, "val": "010203" }, { "len": 4, "val": [ 1, 2, 3, 4 ] }, { "len": 4, "val": [ { "len": 4, "val": "AAAA" }, { "len": 4, "val": "BBB" }, { "len": 4, "val": "CC" }, { "len": 4, "val": "D" } ] }, false ], [ 2, { "len": 7, "val": "string2" }, null, null, null, true ] ] }DELETE
The
DELETErequest deletes individual objects, as specified by the query arguments. This method supports the samecountandskipquery arguments asGET.Only the HTTP result code is returned.
For example the following request delete the first object in the index:
DELETE http://localhost:8083/api/db/xsqldb/classes/3/byindex/0/listThe following request deletes the second and the third objects:
DELETE http://localhost:8083/api/db/xsqldb/classes/3/byindex/0/list?skip=1&count=2