Limit the resultset to `n` records
@class Model
@method limit
@param {integer} limit - The limit as a number.
@param {integer} offset - Optional offset.

@see Model.exec

@return {Model}
485245
function(limit, offset) {
    const self = this.chain()._unresolve() // if the collection is already resolved, return a unresolved and empty copy!

    offset = offset || self.getInternal('offset') || 0

    if (typeof limit === 'string') limit = parseInt(limit)
    if (typeof offset === 'string') offset = parseInt(offset)

    if (!isNaN(limit)) {
      self.setInternal('limit', limit)
      self.setInternal('no_relation_cache', true)
    }
    if (!isNaN(offset)) {
      self.setInternal('offset', offset)
      self.setInternal('no_relation_cache', true)
    }

    if (!limit) {
      self.clearInternal('offset', offset)
      self.clearInternal('limit', limit)
    }

    return self
  }
1344751
function(offset, limit){
    var oldOffset = this.offset;
    var oldLimit = this.limit;
    var delta = false;

    if (oldOffset != offset || oldLimit != limit)
    {
      this.offset = offset;
      this.limit = limit;

      delta = this.applyRule();

      this.emit_rangeChanged(oldOffset, oldLimit);
    }

    return delta;
  }
349508
function createQueryWithLimit() {
            // We query only limit number in case of big table
            // If we query with more than million data query will hang up
            const query = _this.initQuery(namespace);
            if (ancestors) {
                query.hasAncestor(_this.gstore.ds.key(ancestors.slice()));
            }
            query.select('__key__');
            query.limit(limitDataPerQuery);

            return query;
        }
488111
def limit(self, limit):
    
    params = join_params(self.parameters, {"limit": limit})

    return self.__class__(**params)
821165
public function setLimit($count, $offset = null)
    {
        $this->_dsql()->limit($count, $offset);

        return $this;
    }
570924
public function setOffsetLimit($offset, $limit)
    {
        $this->offset = $offset;
        $this->limit = $limit;
        $this->paginationType = self::OFFSET_LIMIT_PAGINATION;
    }
1353343
public function applyLimit(&$sql, $offset, $limit)
    {
        $offset = (int) $offset;
        $limit = (int) $limit;

        if ($limit >= 0) {
            $sql .= ' LIMIT ' . ($offset > 0 ? $offset . ', ' : '') . $limit;
        } elseif ($offset > 0) {
            $sql .= ' LIMIT ' . $offset . ', 18446744073709551615';
        }
    }
1287118
public function limit($limit, $offset = null)
    {
        if ($offset) {
            $this->getLimit()->setParams(array($limit, $offset));
        } else {
            $this->getLimit()->setParams(array($limit));
        }

        return $this;
    }
211162
public function limit($limit = null) {
		if (is_null($limit)) //remove options
			return $this->discard('query.limit');
	
		return $this->merge(['query.limit' => intval($limit)]);
	}
202959
def count(limit = false)
      command = { count: collection.name, query: selector }
      command.merge!(skip: operation.skip, limit: operation.limit) if limit
      result = collection.database.command(command)
      result["n"].to_i
    end
427801
public function limit($offset, $limit)
	{
		$data = array_slice($this->data, $offset, $limit);
		$this->setData($data);

		return $this;
	}
1081511
def fetch(self, limit, offset=0):
        """"""
        self.limit = limit
        self.offset = offset
        return self
401917
public function limit($limit, $offset = null)
    {
        $self              = self::getInstance();
        $offset            = (!empty($offset)) ? 'OFFSET '.$offset : null;
        $self->optionLimit = " LIMIT {$limit} ".$offset;

        return $self;
    }
293846
private function build_limit( $limit, $offset ) {
		$sql = '';
		if ( isset( $limit ) && $limit > 0 ) {
			if ( isset( $offset ) && $offset > 0 ) {
				$sql .= " LIMIT {$offset}, {$limit}";
			} else {
				$sql .= " LIMIT {$limit}";
			}
		}

		return $sql;
	}
460489
def limit(num)
      relation = __new_relation__(all.take(num))
      relation.send(:set_from_limit)
      relation
    end
659430
public static function logic($offset, $limit, $nowCount = 0)
    {
        $offset = (int) $offset;
        $limit = (int) $limit;
        $nowCount = (int) $nowCount;

        $offset = $offset >= 0 ? $offset : 0;
        $limit = $limit >= 0 ? $limit : 0;
        $nowCount = $nowCount >= 0 ? $nowCount : 0;

        /*
         * Means that you should get all
         */
        if ($offset === 0 && $limit === 0 && $nowCount === 0) {
            return new OffsetLogicResult(0, 0);
        }

        if ($offset === 0 && $limit > 0 && $nowCount === 0) {
            return new OffsetLogicResult(1, $limit);
        }

        if ($offset > 0 && $limit === 0) {
            return new OffsetLogicResult(2, $nowCount + $offset);
        }

        if ($nowCount > 0) {
            if ($limit > $nowCount) {
                return static::logic($offset + $nowCount, $limit - $nowCount);
            }
            /*
             * Means that you should stop fetching
             */
            throw new AlreadyGetNeededCountException('Limit <= no count. You should stop asking (:');
        }

        if ($offset > 0 && $limit > 0) {
            if ($offset === $limit) {
                return new OffsetLogicResult(2, $limit);
            }
            if ($offset < $limit) {
                return new OffsetLogicResult(2, $offset);
            }
            if ($offset > $limit) {
                for ($i = $limit; $i > 0; $i--) {
                    if ($offset % $i === 0) {
                        return new OffsetLogicResult(
                            ($offset / $i) + 1,
                            $i
                        );
                    }
                }
            }
        }

        /*
         * Really its can be here oO
         */
        throw new \LogicException('Something gone wrong');
    }
425998
public function limit($limit, $offset = null) {
		$this->_criteria->limit($limit, $offset);
		$this->_limit = (int) $limit;
				
		return $this;
	}