iron router - Error: Unrecognized operator: $nearSphere in meteor js -


i have simple code in meteor js find near garages within 10 kilometres query works fine in mongodb database if run manually in robomongo works fine when run in routes throws error. this.

error: unrecognized operator: $nearsphere in meteor jsi 

i see blogs said need call server side method this. use below code call server side route.

router.route('/search/:name',                     {name:'searchlist',                         data:function(){                              var searchedparams = this.params.name.split('-');                              var lat = searchedparams.pop();                             var lng = searchedparams.pop(1);                              return {searchvalue: centers.find({ coordinates: { $nearsphere: { $geometry: { type: "point", coordinates: [lng,lat] }, $maxdistance: 10000 } } })}                              }                            }, { where: "server" }                       ); 

if have idea please help.

you're mixing definitions client , server side routes.

server-side route should this:

router.route('/search/:name', function(...){...}, { where: 'server' }); 

client-side route could this:

router.route('/search/:name, { ... }); 

thus, route client-side route , minimongo doesn't have support $nearsphere operator noted here: https://github.com/meteor/meteor/blob/devel/packages/minimongo/notes


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -