Skip to content

Commit

Permalink
added example to get users count
Browse files Browse the repository at this point in the history
  • Loading branch information
Hovhannes Babayan committed Dec 26, 2014
1 parent a4082ef commit 945d0da
Showing 1 changed file with 38 additions and 0 deletions.
38 changes: 38 additions & 0 deletions examples/node/get-user-count.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/**
* Logs in, returns number of active users
*/

var ApiFactory = require('./../../').ApiFactory;
var ApiConstants = require('./../../').ApiConstants;
var util = require('util');

var instance = ApiFactory.getInstance({
hostname: 'localhost',
version: '5.0',
port: 8080
});

util.print('Logs in, returns number of active users\n');
util.log('Logging in ...');
instance.login('new@user.attask', 'user').then(
function() {
util.log('Getting number of active users ...');
var query = {};
query['isActive'] = true;
query['isActive' + ApiConstants.MOD] = ApiConstants.Operators.EQUAL;
instance.count('user', query).then(
function(data) {
util.log('Get success. Received data:');
console.log(util.inspect(data, {colors:true}));
},
function(error) {
util.log('Get failure. Received data:');
console.log(util.inspect(error, {colors:true}));
}
);
},
function(error) {
util.log('Login failure. Received data:');
console.log(util.inspect(error, {colors:true}));
}
);

0 comments on commit 945d0da

Please sign in to comment.