Skip to content

Instantly share code, notes, and snippets.

@hebuliang
Created May 16, 2012 14:10
Show Gist options
  • Save hebuliang/2710635 to your computer and use it in GitHub Desktop.
Save hebuliang/2710635 to your computer and use it in GitHub Desktop.
jSQL count function
count: function(key) {
var count = 0, scope = key.split('.');
if(key === '*')
this._buffer = this._currentDB;
for(var key in this._currentDB) {
if (this._currentDB.hasOwnProperty(key)) {
var tmp = this._currentDB[key];
for(var i=0,j=0; i<(j=scope.length); i++) {
tmp = tmp[scope[i]];
if(!!tmp && i == j - 1) count++;
}
}
return count;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment