John Polling
unread,May 16, 2011, 9:49:31 AM5/16/11Sign in to reply to author
Sign in to forward
You do not have permission to delete messages in this group
Either email addresses are anonymous for this group or you need the view member email addresses permission to view the original message
to MongoMapper
Hi,
A bit of beginners question I'm afraid. I've got this query running
in Mongo just fine
db.users.find({ location : { $within : { $centerSphere : [[x, y],
650/3595] } }, $where : "Geo.sphereDistance( this.location, [x, y] ) <
this.radius" })
This basically allows me to make get users within a set distance, but
to also check their radius meets the relevant x,y so I can filter out
users who have a smaller radius.
I'm a bit stuck as to how to convert that query into a query
mongomapper can read? I've so far got
User.where({ :location => { '$within' => { '$centerSphere' =>
[[52.8444573, -0.435423], 650.to_f/3595.to_f] } }, '$where' =>
"Geo.sphereDistance( this.location, [52.8444573, -0.435423] ) <
70.to_f/3595.to_f" }).all
However I'm getting the following error:
Mongo::OperationFailure: $where compile error
Any help would be greatly appreciated.
John