query

DatabaseUser.query(dbId, params[, token])

Queries users from the database.

Parameters

This method has the following parameters:

ArgumentDescription
dbIdString with database id.
tokenString with user token.
paramsJSON 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:

ParameterTypeDescription
criteriaJSONQuery object built in accordance with the mongo querying.
skipintegerParameter indicating how much objects should be skipped before including objects into response.
limitintegerParameter indicating how many objects should be included in response.
countbooleanParameter indicating whether the number of selected objects should be included in response.
sortstringList of fields names split by comma that indicates the order of objects in response.
includestringParameter 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);