How to execute runCommand with Mongoose?

前端 未结 4 486
一生所求
一生所求 2021-02-07 13:28

I am using Node.js and Mongoose to access my MongoDB. I am using a model that stores some geo coordinates. I have them indexed and everything seems to work as expected. What I a

4条回答
  •  闹比i
    闹比i (楼主)
    2021-02-07 14:00

    Hope this should work!! Referrence URL : http://mongoosejs.com/docs/api.html

    // Legacy point

    Model.geoNear([1,3], { maxDistance : 5, spherical : true }, function(err, results, stats) {
       console.log(results);
    });
    

    // geoJson

    var point = { type : "Point", coordinates : [9,9] };
    Model.geoNear(point, { maxDistance : 5, spherical : true }, function(err, results, stats) {
       console.log(results);
    });
    

提交回复
热议问题