How to get row counter from azure database?

I am working on a javascript application for a windows store. The application uses data from azure mobile services. Consider the code below:

var itemTable = mobileService.getTable('item');
//item is the table name stored in the azure database

The code retrieves the entire table itemand stores it in a variable itemTable.

What code will return no lines present in itemTable??

+5
source share
3 answers

What you are looking for is a method includeTotalCountfor the table / query object (unfortunately, it is not in the documentation, I will write an error in the product command so that it is fixed).

read , 50 (IIRC, ) , ( , ). , .

, , , : .

    var table = client.getTable('tableName');
    table.take(0).includeTotalCount().read().then(function (results) {
        var count = results.totalCount;
        new Windows.UI.Popups.MessageDialog('Total count: ' + count).showAsync();
    });

, (.. ), take() skip(), includeTotalCount.

+5

- , totalCount # ( ), :

var table =  MobileService.GetTable<T> ();
var query = table.Take(0).IncludeTotalCount();
IList<T> results = await query.ToListAsync ();
long count = ((ITotalCountProvider)results).TotalCount;

+4

You need to execute read()in the query table and then get the lengthresults.

var items, numItems;
itemTable.read().then(function(results) { items = results; numItems = items.length; });

If you show only the number of records, and not all the results, you should simply select the identifier column to reduce the amount of data transferred. I do not see the JS Query API count() to satisfy this need.

var itemTable = mobileService.getTable('item').select('itemID');
+2
source

All Articles