QB Near - Bad Docblock #47

datasage opened this Issue Apr 20, 2012 · 0 comments


None yet

2 participants


It appears that this function is documented inconsistently. It looks like the code expects an array.

     * Add where near criteria.
     * @param string $x
     * @param string $y
     * @return Builder
    public function near($value)
        $this->query['type'] = Query::TYPE_GEO_LOCATION;
        $this->query['near'][$this->currentField] = $value;
        return $this;

It looks like there are larger issues than that. Since the code is using geoNear command to run the query, the field is irrelevant and it appears to break. Mongo will use the only geoindex on the collection.

This line:

$this->query['near'][$this->currentField] = $value;

Should probably be changed to:

$this->query['near'] = $value;
@jmikola jmikola added a commit that closed this issue Jul 12, 2012
@jmikola jmikola Revise support for geoNear commands and $near query criteria
Fixes #47. Previously, the near() builder method was used to support the geoNear command instead of $near query criteria. This was unintuitive, given how other geo methods like withinBox() operated.

Instead, we add a new geoNear() builder method, which operates similarly to mapReduce() and switches the query into GEO_LOCATION mode. We also add methods to specify the distanceMultipler and maxDistance options.

The near() builder method is repurposed to define $near query criteria for a field or expression.
@jmikola jmikola closed this in 6637851 Jul 12, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment