src/server/storage/storagehelpers.js
function loadPath(dbProject, rootHash, loadedObjects, path, excludeParents) {
    var deferred = Q.defer(),
        pathArray = path.split('/');

    function processLoadResult(hash, result) {
        var subHash;
        if (result.multipleObjects === true) {
            for (subHash in result.objects) {
                loadedObjects[subHash] = result.objects[subHash];
            }
        } else {
            loadedObjects[hash] = result;
        }
    }

    function loadParent(parentHash, relPath) {
        var hash;
        if (loadedObjects[parentHash]) {
            // Object was already loaded.
            if (relPath) {
                hash = loadedObjects[parentHash][relPath];
                loadParent(hash, pathArray.shift());
            } else {
                deferred.resolve();
            }
        } else {
            loadObject(dbProject, parentHash)
                .then(function (object) {
                    if (relPath) {
                        hash = object[relPath];
                        if (!excludeParents) {
                            processLoadResult(parentHash, object);
                        }
                        loadParent(hash, pathArray.shift());
                    } else {
                        processLoadResult(parentHash, object);
                        deferred.resolve();
                    }
                })
                .catch(function (err) {
                    deferred.reject(err);
                });
        }
    }

    // Remove the root-path
    pathArray.shift();

    loadParent(rootHash, pathArray.shift());
    return deferred.promise;
}
function loadPath(dbProject, rootHash, loadedObjects, path, excludeParents) {
    var deferred = Q.defer(),
        pathArray = path.split('/');

    function processLoadResult(hash, result) {
        var subHash;
        if (result.multipleObjects === true) {
            for (subHash in result.objects) {
                loadedObjects[subHash] = result.objects[subHash];
            }
        } else {
            loadedObjects[hash] = result;
        }
    }

    function loadParent(parentHash, relPath) {
        var hash;
        if (loadedObjects[parentHash]) {
            // Object was already loaded.
            if (relPath) {
                hash = loadedObjects[parentHash][relPath];
                loadParent(hash, pathArray.shift());
            } else {
                deferred.resolve();
            }
        } else {
            loadObject(dbProject, parentHash)
                .then(function (object) {
                    if (relPath) {
                        hash = object[relPath];
                        if (!excludeParents) {
                            processLoadResult(parentHash, object);
                        }
                        loadParent(hash, pathArray.shift());
                    } else {
                        processLoadResult(parentHash, object);
                        deferred.resolve();
                    }
                })
                .catch(function (err) {
                    deferred.reject(err);
                });
        }
    }

    // Remove the root-path
    pathArray.shift();

    loadParent(rootHash, pathArray.shift());
    return deferred.promise;
}
function loadPath ( dbProject , rootHash , loadedObjects , path , excludeParents ) { var deferred = Q . defer ( ) , pathArray = path . split ( '/' ) ; function processLoadResult ( hash , result ) { var subHash ; if ( result . multipleObjects === true ) { for ( subHash in result . objects ) { loadedObjects [ subHash ] = result . objects [ subHash ] ; } } else { loadedObjects [ hash ] = result ; } } function loadParent ( parentHash , relPath ) { var hash ; if ( loadedObjects [ parentHash ] ) { // Object was already loaded. if ( relPath ) { hash = loadedObjects [ parentHash ] [ relPath ] ; loadParent ( hash , pathArray . shift ( ) ) ; } else { deferred . resolve ( ) ; } } else { loadObject ( dbProject , parentHash ) . then ( function ( object ) { if ( relPath ) { hash = object [ relPath ] ; if ( ! excludeParents ) { processLoadResult ( parentHash , object ) ; } loadParent ( hash , pathArray . shift ( ) ) ; } else { processLoadResult ( parentHash , object ) ; deferred . resolve ( ) ; } } ) . catch ( function ( err ) { deferred . reject ( err ) ; } ) ; } } // Remove the root-path pathArray . shift ( ) ; loadParent ( rootHash , pathArray . shift ( ) ) ; return deferred . promise ; }
Loads the entire composition chain up till the rootNode for the provided path. And stores the nodes
in the loadedObjects. If the any of the objects already exists in loadedObjects - it does not load it
from the database.

@param {object} dbProject
@param {string} rootHash
@param {Object<string, object>} loadedObjects
@param {string} path
@param {boolean} excludeParents - if true will only include the node at the path
@returns {function|promise}
@ignore
Loads the entire composition chain up till the rootNode for the provided path . And stores the nodes in the loadedObjects . If the any of the objects already exists in loadedObjects - it does not load it from the database .