jstests/aggregation/sources/geonear/geonear_let.js
/**
 * Compare pipelines with constant and variable 'near' argument.
 */
Compare pipelines with constant and variable 'near' argument.
Compare pipelines with constant and variable ' near ' argument .
function compareResults(nearArgument) {
    const pipeline = [{$geoNear: {near: "$$pt", distanceField: "distance"}}];
    const res = coll.aggregate(pipeline, {let : {pt: nearArgument}}).toArray();
    const constRes =
        coll.aggregate([{$geoNear: {near: nearArgument, distanceField: "distance"}}]).toArray();
    assert.eq(res.length, constRes.length);
    for (let i = 0; i < res.length; i++) {
        assert.eq(res[i].distance, constRes[i].distance);
    }
}
function compareResults ( nearArgument ) { const pipeline = [ { $geoNear : { near : "$$pt" , distanceField : "distance" } } ] ; const res = coll . aggregate ( pipeline , { let : { pt : nearArgument } } ) . toArray ( ) ; const constRes = coll . aggregate ( [ { $geoNear : { near : nearArgument , distanceField : "distance" } } ] ) . toArray ( ) ; assert . eq ( res . length , constRes . length ) ; for ( let i = 0 ; i < res . length ; i ++ ) { assert . eq ( res [ i ] . distance , constRes [ i ] . distance ) ; } }
Compare pipelines with constant and variable 'near' argument.
Compare pipelines with constant and variable ' near ' argument .