简体   繁体   中英

GeoSpatial indexing in node-mongodb-native or mongoose?

I'm currently building a webserver in nodeJS that'll be using mongoDB. One of the main reasons that I picked mongoDB over other databases is that it features geospatial indexing that's integral to my app. That said, I can't seem to find any information on how to do this using any of the node drivers. I've found questions on google groups where people have asked what they're doing wrong with their geospatial indexing code, so I'm assuming that it's possible, but I just can't find any information on it anywhere. I've looked through the node-mongodb-native source code, but I wasn't able to find anything there (though I easily could have skipped it or just not known what to look for exactly).

Does anybody have any idea how to run these commands in nodeJS? http://www.mongodb.org/display/DOCS/Geospatial+Indexing Alternatively if anybody knows where in the node-mongodb-native source code these commands exist, that would also be awesome.

Best and thanks,
Sami

I think you can just pass an array with options, say to the find command, as outlined here .

So taking one example from the MongoDB site, you could just pass this type of object into the find() function

{ "location" : { "$near" : [50,50] }, "category" : "coffee" }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM