src/server/storage/storagehelpers.js
function loadObject(dbProject, nodeHash) {
    var deferred = Q.defer(),
        node;

    dbProject.loadObject(nodeHash)
        .then(function (node_) {
            var shardLoads = [],
                shardId;
            node = node_;

            if (node && node.ovr && node.ovr.sharded === true) {
                for (shardId in node.ovr) {
                    if (REGEXP.DB_HASH.test(node.ovr[shardId]) === true) {
                        shardLoads.push(dbProject.loadObject(node.ovr[shardId]));
                    }
                }
                return Q.allSettled(shardLoads);
            } else {
                deferred.resolve(node);
                return;
            }
        })
        .then(function (overlayShardResults) {
            var i,
                response = {
                    multipleObjects: true,
                    objects: {}
                };
            response.objects[nodeHash] = node;

            for (i = 0; i < overlayShardResults.length; i += 1) {
                if (overlayShardResults[i].state === 'rejected') {
                    throw new Error('Loading overlay shard of node [' + nodeHash + '] failed');
                } else if (overlayShardResults[i].value._id) {
                    response.objects[overlayShardResults[i].value._id] = overlayShardResults[i].value;
                }
            }

            deferred.resolve(response);
        })
        .catch(deferred.reject);

    return deferred.promise;
}
function loadObject(dbProject, nodeHash) {
    var deferred = Q.defer(),
        node;

    dbProject.loadObject(nodeHash)
        .then(function (node_) {
            var shardLoads = [],
                shardId;
            node = node_;

            if (node && node.ovr && node.ovr.sharded === true) {
                for (shardId in node.ovr) {
                    if (REGEXP.DB_HASH.test(node.ovr[shardId]) === true) {
                        shardLoads.push(dbProject.loadObject(node.ovr[shardId]));
                    }
                }
                return Q.allSettled(shardLoads);
            } else {
                deferred.resolve(node);
                return;
            }
        })
        .then(function (overlayShardResults) {
            var i,
                response = {
                    multipleObjects: true,
                    objects: {}
                };
            response.objects[nodeHash] = node;

            for (i = 0; i < overlayShardResults.length; i += 1) {
                if (overlayShardResults[i].state === 'rejected') {
                    throw new Error('Loading overlay shard of node [' + nodeHash + '] failed');
                } else if (overlayShardResults[i].value._id) {
                    response.objects[overlayShardResults[i].value._id] = overlayShardResults[i].value;
                }
            }

            deferred.resolve(response);
        })
        .catch(deferred.reject);

    return deferred.promise;
}
function loadObject ( dbProject , nodeHash ) { var deferred = Q . defer ( ) , node ; dbProject . loadObject ( nodeHash ) . then ( function ( node_ ) { var shardLoads = [ ] , shardId ; node = node_ ; if ( node && node . ovr && node . ovr . sharded === true ) { for ( shardId in node . ovr ) { if ( REGEXP . DB_HASH . test ( node . ovr [ shardId ] ) === true ) { shardLoads . push ( dbProject . loadObject ( node . ovr [ shardId ] ) ) ; } } return Q . allSettled ( shardLoads ) ; } else { deferred . resolve ( node ) ; return ; } } ) . then ( function ( overlayShardResults ) { var i , response = { multipleObjects : true , objects : { } } ; response . objects [ nodeHash ] = node ; for ( i = 0 ; i < overlayShardResults . length ; i += 1 ) { if ( overlayShardResults [ i ] . state === 'rejected' ) { throw new Error ( 'Loading overlay shard of node [' + nodeHash + '] failed' ) ; } else if ( overlayShardResults [ i ] . value . _id ) { response . objects [ overlayShardResults [ i ] . value . _id ] = overlayShardResults [ i ] . value ; } } deferred . resolve ( response ) ; } ) . catch ( deferred . reject ) ; return deferred . promise ; }
Loads the specific object, and if that object represents a node with sharded overlays,
then it loads those objects as well, and pack it into a single response.

@param {object} dbProject
@param {string} nodeHash
@returns {function|promise}
@ignore
Loads the specific object and if that object represents a node with sharded overlays then it loads those objects as well and pack it into a single response .