Suggested additions to the Data class
Currently there is no simple way to find out how many data entries there are in a site.
I can use data.keys.length, but only while the site contains less than 1000 entries. Similarly, data.getEntries( string1, string2 ).length will only work while the site contains less than 500 entries.
Once the number of entries exceeds those limits, the only reliable way to establish how many entries there are is to go through a loop along the lines of retrieving data.keys, counting the length of the resulting array, and then if it's 1000, retrieve data.getKeys( 1000 ), if the length of that is 1000 then retrieve data.getKeys( 2000 ), and so on.
All this is a bit long winded, and probably rather memory intensive, especially when all I want is the number of entries rather than the values of all those entries.
So, could we have some new properties and methods on the data class, similar to the keys property and the getKeys method, but which return just the number of entries rather than an array of their values?
Thanks,
Simon
Posted at 2:42 AM on February 10, 2009
Simon,
Thanks for the suggestion. It's an easy enough thing to add. I'll make a note of it. The data class is used for all sorts of different things and wanting to know the complete number of entries could be akin to wanting to how many records there are in all the tables in a database - not something you'd need often. As keys are typically segmented by key prefixes, it would make sense for a count property to support an optional key prefix as well. For example, it would make sense to want to know how many contact.* entries there are in a contact management application.
Cheers,
Matt
Posted at 8:45 PM on February 10, 2009