Adrian Short hace 12 años
commit
727f6dcee6
Se han modificado 1 ficheros con 26 adiciones y 0 borrados
  1. +26
    -0
      post.rb

+ 26
- 0
post.rb Ver fichero

@@ -0,0 +1,26 @@
class Post
include MongoMapper::Document

key :title, String
key :url, String
key :author, String
key :summary, String
key :content, String
key :published, Time
key :loc, Hash # { lng, lat }
timestamps!

ensure_index [[:loc, '2d']]

belongs_to :feed
EARTH_RADIUS_M = 6378000
def self.near(lat, lng, radius_m)
all(
:loc => {
'$nearSphere' => [ lng, lat ],
'$maxDistance' => radius_m / EARTH_RADIUS_M
})
end
end

Cargando…
Cancelar
Guardar