querySubjects
This method returns a list of subjects owned by the current user.
This method was added in Cortex 2.1
Parameters
Name | Type | Required | Description |
cortexToken |
| yes | A token returned by authorize. |
query |
| yes | An object to filter the subjects. |
orderBy |
| yes | Specify how to sort the subjects. |
limit |
| no | The maximum number of subjects that this method should return. A limit of zero means no maximum. |
offset |
| no | The number of subjects that this method should skip before returning the result. If the limit is zero, then Cortex will ignore this parameter. |
Depending on the query, this method may return a lot of subjects. To avoid performance issues, you should always set an offset and a limit.
query
The query object can contain one or more of these fields:
Name | Type | Description |
uuid |
| Set this parameter to get a subject by its id. |
subjectName |
| Set this parameter to filter the subjects by name. |
sex |
| Set this parameter to filter the subjects by their gender. Must be "M", "F" or "U". |
countryCode |
| Set this parameters to filter the subjects by their country. |
dateOfBirth |
| An object with fields "from" and "to" to filter the subjects by their date of birth. |
keyword |
| An object with the fields as the keyword to search and values are the list of fields to search. The list of fields to search can contains "subjectName", "lastName", "email" |
orderBy
The orderBy parameters is an array of objects, similar to the orderBy clause of a SQL request.
Each object must have a single attribute. The key of the attribute is the name of subject's field you want to order by. The value of the attribute must be "ASC" or "DESC", to order is ascending or descending order.
For example, to order the subjects by their names, in alphabetical order, you must use the object {"subjectName":"ASC"}
.
You can order the subjects by these fields: subjectName, dateOfBirth.
limit and offset
These parameters are to implement pagination. It useful if you want to display the subjects in a UI. You must order the results to use these parameters.
First you should call this method with a offset of zero, and a limit of X. In the response, check the value of count. If count is greater than the limit, then you should call this method again with an offset of X. And then with an offset of 2*X, 3*X... until you get all the subjects for your query.
Result
The result is an object that includes these fields:
Name | Type | Description |
subjects |
| An array of subject objects. |
count |
| The total number of subjects that match the query. |
limit |
| The limit you specified in the parameters. |
offset |
| The offset you specified in the parameters. |
Examples
Find the 10 first female subjects born in 1979 or 1980.
Last updated