Comments (11)
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.
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.
{
"error": "no geo indices for geoNear"
}
after use, this code got this response
from rest-api-playlist.
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.
It worked for me. Thanks
from rest-api-playlist.
It doesn’t return anything for me😫
from rest-api-playlist.
from rest-api-playlist.
using geoNear function is not working. It is not returning anything
from rest-api-playlist.
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.
It doesn’t return anything for me😫
same for me
from rest-api-playlist.
Thanks a lot. It worked for me.
from rest-api-playlist.
Related Issues (20)
- GeoJSON HOT 6
- console.log() not working
- Cant find css file HOT 2
- Body-parser doesn't return `res.body`
- Request, can you please make a video of...
- Lesson 14 - .geoNear no longer supported use .aggregate in mongoose 5+ HOT 2
- Cannot read property 'available' of undefined HOT 3
- .map no longer working
- For updating
- Type error HOT 2
- lesson 1 missing
- "geo near accepts just one argument when querying for a GeoJSON point. Extra field found: $maxDistance: 100000.0"
- Lesson 14, geoNear depreciated, .aggregate is used.
- No files HOT 2
- ValidationError: name: Name field is required HOT 1
- Mongoose.connect() deprication issue HOT 5
- React.createClass deprication issue in react@15
- React with ES6 HOT 8
- Frontend Authentication HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rest-api-playlist.