DatabaseUser.query(dbId, params[, token])
Queries users from the database.
Parameters
This method has the following parameters:
Argument | Description |
---|---|
dbId | String with database id. |
token | String with user token. |
params | JSON object that contains request parameters. |
JSON object params has the following structure:
{
["criteria":<criteria>,]
["skip":<skip>, ]
["limit":<limit>, ]
["count":<count>, ]
["sort":<sort>, ]
["include":<include> ]
}
params JSON parameters:
Parameter | Type | Description |
---|---|---|
criteria | JSON | Query object built in accordance with the mongo querying. |
skip | integer | Parameter indicating how much objects should be skipped before including objects into response. |
limit | integer | Parameter indicating how many objects should be included in response. |
count | boolean | Parameter indicating whether the number of selected objects should be included in response. |
sort | string | List of fields names split by comma that indicates the order of objects in response. |
include | string | Parameter that indicates whether the referenced object should be included. |
Response
JSON object with a list of users
[{
"username": <username > ,
"_createdAt": <datetime > ,
"_updatedAt": <datetime > ,
"_id": <user_id >
}, ...]
Example
Queryingusers from the database.
var dbId = "52776916a044652b54f1f976";
var username = "testUser10";
var password = "testUser10";
var token = DatabaseUser.login(dbId, username, password).sessionToken;
var query = DatabaseUser.query(dbId, {
"skip": 1,
"limit": 1
}, token);