You are viewing a plain text version of this content. The canonical link for it is here.
Posted to oak-commits@jackrabbit.apache.org by mr...@apache.org on 2016/06/27 06:44:34 UTC
svn commit: r1750279 - /jackrabbit/oak/trunk/oak-run/src/main/js/oak-mongo.js
Author: mreutegg
Date: Mon Jun 27 06:44:34 2016
New Revision: 1750279
URL: http://svn.apache.org/viewvc?rev=1750279&view=rev
Log:
OAK-4507: [oak-mongo.js] oak.indexStats() does not compute counts properly
Applied patch provided by Kevin Wellenzohn
Modified:
jackrabbit/oak/trunk/oak-run/src/main/js/oak-mongo.js
Modified: jackrabbit/oak/trunk/oak-run/src/main/js/oak-mongo.js
URL: http://svn.apache.org/viewvc/jackrabbit/oak/trunk/oak-run/src/main/js/oak-mongo.js?rev=1750279&r1=1750278&r2=1750279&view=diff
==============================================================================
--- jackrabbit/oak/trunk/oak-run/src/main/js/oak-mongo.js (original)
+++ jackrabbit/oak/trunk/oak-run/src/main/js/oak-mongo.js Mon Jun 27 06:44:34 2016
@@ -86,6 +86,12 @@ var oak = (function(global){
* @returns {number} the number of children, including all descendant nodes.
*/
api.countChildren = function(path){
+ if (path === undefined) {
+ return 0;
+ } else if (path != "/") {
+ path = path + "/";
+ }
+
var depth = pathDepth(path);
var totalCount = 0;
while (true) {
@@ -130,6 +136,10 @@ var oak = (function(global){
* parameter of the function.
*/
api.forEachChild = function(path, callable) {
+ if (path !== undefined && path != "/") {
+ path = path + "/";
+ }
+
var depth = pathDepth(path);
while (true) {
var cur = db.nodes.find({_id: pathFilter(depth++, path)});