Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get the item count (size) of a dojo datastore?

Tags:

dojo

I don't see anything in the read API that provides access to this: http://api.dojotoolkit.org/jsdoc/1.3.2/dojo.data.api.Read

like image 742
Arlo Avatar asked Oct 27 '09 23:10

Arlo


Video Answer


2 Answers

An example at dojocampus demonstrates one way. Here a fetch without query parameter returns all the items in the store.

var store = new some.Datastore();
var gotItems = function(items, request){
  console.log("Number of items located: " + items.length);
};
store.fetch({onComplete: gotItems});
like image 56
Maine Avatar answered Oct 12 '22 08:10

Maine


dojo.data.api.Read's onBegin function has the total size of the match:

function size(size, request){
  // Do whatever with the size var.
}

store.fetch({query: {}, onBegin: size, start: 0, count: 0});

From this quickstart: http://dojotoolkit.org/reference-guide/1.7/quickstart/data/usingdatastores/faq.html#question-6-how-do-i-get-a-count-of-all-items-in-a-datastore

like image 34
voidstate Avatar answered Oct 12 '22 08:10

voidstate