Getting the Item Count

The get count operation returns the number of result items instead of the items themselves. This can save you bandwidth and processing on the client.

Note

If you want to count grouped data, use the count() aggregation function; the Query count() function does not support aggregated/grouped data.

The following example returns the count of all items stored in the Books content type.

var el = new Everlive('your-app-id');
var data = el.data('Books');
data.count()
    .then(function(data){
        alert(JSON.stringify(data));
    },
    function(error){
        alert(JSON.stringify(error));
    });

You can apply the same function to filtered results. For example, you can request the count of books written by a single author.

var el = new Everlive('your-app-id');
var data = el.data('Books');
data.count({ 'Author': 'John Doe'}, // filter
    function(data){
        alert(JSON.stringify(data));
    },
    function(error){
        alert(JSON.stringify(error));
    });

You can also pass an instance of Everlive.Query as a filter instead of a plain object.

Note

The second code snippet does not use the then() function. Instead, the callbacks are passed as arguments. Both syntaxes are allowed. Use the one you find more convenient.

See Also

Start a free trial Request a demo
Contact us: +1-888-365-2779
sales@telerik.com
Copyright © 2016-2017, Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.