Example #1
0
  return function getAllClosure(ctx, key, starting, ending, options, callback) {
    var iter, iterOptions = {}, result = [], includeChildren, marker, tmp;

    if (!options.hasOwnProperty('includeChildren')) {
      includeChildren = true;
    }
    else {
      includeChildren = options.includeChildren;
    }

    tmp = exports.getIterOptions(Obj, ctx, starting, options);

    if (tmp.starting) {
      starting = tmp.starting;
    }

    iterOptions.limit = tmp.limit;
    iterOptions = misc.merge(iterOptions, options);

    iter = new PaginatedObjectIterator(ctx, Obj, iterOptions);

    iter.on('error', callback);

    iter.on('object', function iterOnObject(obj) {
      result.push(obj);
    });

    iter.on('end', function iterOnEnd(data) {
      callback(null, result, data);
    });

    iter.getSliceByKey(key, includeChildren, starting, ending);
  };
Example #2
0
  return function getSomeClosure(ctx, key, includeChildren, starting, ending, options, callback) {
    options = options || {};

    if (!key) {
      throw new errors.ValidationFailureError('key is not specified');
    }

    var result = [], iter, iterOptions = {}, tmp;

    tmp = exports.getIterOptions(Obj, ctx, starting, options);

    if (tmp.starting) {
      starting = tmp.starting;
    }

    iterOptions.limit = tmp.limit;
    iterOptions = misc.merge(iterOptions, options);

    iter = new PaginatedObjectIterator(ctx, Obj, iterOptions);

    iter.on('error', callback);
    iter.on('object', function iterOnObject(obj) {
      result.push(obj);
    });

    iter.on('end', function iterOnEnd(data) {
      callback(null, result, data);
    });

    iter.getSliceByKey(key, includeChildren, starting, ending);
  };