Giter Site home page Giter Site logo

Comments (11)

kc963 avatar kc963 commented on July 17, 2024 19

The current version of mongoose doesn't support geoNear. You will have to use the aggregate function to make use of the geoNear command of MongoDB.

Ninja.aggregate([{ $geoNear: { near: {type: 'Point', coordinates: [parseFloat(req.query.lng), parseFloat(req.query.lat)]}, spherical: true, maxDistance: 100000, distanceField: "dist.calculated" } }]).then(function(results){ res.send(results); });

from rest-api-playlist.

harshitphoenix avatar harshitphoenix commented on July 17, 2024 3

using geoNear function is not working. It is not returning anything

I am having the same issue. Have you resolved it?

router.get("/nin",(req,res,next)=>{

    Ninja.aggregate([{
        $geoNear:{
    near:
    {type:'point',coordinates:[parseFloat(req.query.lng),parseFloat(req.query.lat)]},
    spherical: true ,maxdistance :100000,distanceField: "dist.calulated"}
    }]).then(function(ninjas){
    res.send(ninjas)
    })

});

try using this...it worked for me.

from rest-api-playlist.

ammubhardwaj4 avatar ammubhardwaj4 commented on July 17, 2024

{
"error": "no geo indices for geoNear"
}

after use, this code got this response

from rest-api-playlist.

s-katte avatar s-katte commented on July 17, 2024

The current version of mongoose doesn't support geoNear. You will have to use the aggregate function to make use of the geoNear command of MongoDB.

Ninja.aggregate([{ $geoNear: { near: {type: 'Point', coordinates: [parseFloat(req.query.lng), parseFloat(req.query.lat)]}, spherical: true, maxDistance: 100000, distanceField: "dist.calculated" } }]).then(function(results){ res.send(results); });

how to use that aggregate finction?

from rest-api-playlist.

amarbessedik avatar amarbessedik commented on July 17, 2024

It worked for me. Thanks

from rest-api-playlist.

GISSIAH avatar GISSIAH commented on July 17, 2024

It doesn’t return anything for me😫

from rest-api-playlist.

Dawoodjaveed avatar Dawoodjaveed commented on July 17, 2024

from rest-api-playlist.

harshitphoenix avatar harshitphoenix commented on July 17, 2024

using geoNear function is not working. It is not returning anything

from rest-api-playlist.

Godswill199 avatar Godswill199 commented on July 17, 2024

using geoNear function is not working. It is not returning anything

I am having the same issue. Have you resolved it?

from rest-api-playlist.

krishchvn avatar krishchvn commented on July 17, 2024

It doesn’t return anything for me😫

same for me

from rest-api-playlist.

Asmovic avatar Asmovic commented on July 17, 2024

Thanks a lot. It worked for me.

from rest-api-playlist.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.