Example #1
0
    t.count = function (b, l, cbk) {
      var getArgs = {
        reduce: true
      };

      var startkey = viewArgs.startkey;
      var endkey = viewArgs.endkey;


      if (startkey) {
        getArgs.startkey = startkey;
      }
      if (endkey) {
        getArgs.endkey = endkey;
      }
      that.executeView(viewName, getArgs, l.wrap('executing view'), utils.cb(cbk, function (result) {
        var count = 0;
        if (result.length > 0) {
          count = result[0];
        }
        cbk(null, {
          count: count
        });
      }));
    };
Example #2
0
    t.get = function (b, l, cbk) {

      var startkey = viewArgs.startkey;
      var endkey = viewArgs.endkey;


      if (!b.skip || b.skip < 0) {
        b.skip = 0;
      }

      var getArgs = {
        reduce: false
      };

      if (typeof b.skip !== 'undefined') {
        getArgs.skip = b.skip;
      }
      if (typeof b.limit !== 'undefined') {
        getArgs.limit = b.limit;
      }
      if (typeof startkey !== 'undefined') {
        getArgs.startkey = startkey;
      }
      if (typeof endkey !== 'undefined') {
        getArgs.endkey = endkey;
      }

      that.executeView(viewName, getArgs, l.wrap('executing view'), utils.cb(cbk, function (result) {
        cbk(null, {
          got: result
        });
      }));
    };