It would be nice if client side scripts could inquire about the ‘number of matching objects’ without first having to query/receive all the matching object data (key/value pairs).
I would assume that (with a large number of matching objects in a Table) it would reduce the time to complete such a task.
I suggest a method ( e.g. .count() ) similar to the .find() …
var contactStorage = Backendless.Persistence.of( Contact );
var dataQuery = {
condition: "age = 21"
};
var numberOfMatchingContacts = contactStorage.count( dataQuery );
We recognize it is not very elegant right now and it is on our roadmap to provide a dedicated method to the object count. Until then, you can do the following which will minimize the data transfer:
var contactStorage = Backendless.Persistence.of( Contact );
var dataQuery = {
condition: "age = 21",
options: {pageSize:1}
};
var matchingContacts = contactStorage.find( dataQuery );
console.log( matchingContacts.totalObjects );