Closed Julian closed 12 years ago
Both are due to constraints of MongoDB:
lat
and lon
are composed into an array so that we can use 2d geospatial indexes on the combined loc
field_id
is the default unique, immutable key of every MongoDB document (effectively a primary key), so rather than having to create an additional index, we use the one the database provides.Rather than taking too much time to refactor the Model
class tree now, I want to spend some time thinking about whether it offers us anything, or if we can remove it. The initial idea was that we could do a lot with load()
, save()
, and refresh()
, but we've sinced moved to doing more with "bulk" operations (API queries and MongoDB find
s that return multiple entities)
_id
is Mongo's version of a primary key. It is a unique value associated with each document. By default, Mongo will store an ObjectId
in the field. We opted to leverage the primary keys provided by meetup.
The reason we opted to use loc
is that Mongo allows for running 2d queries on points.
And of course Dan's answer sounds better than mine. :smile:
Ah awesome, OK. Good to know. So leaving things as they are then. Sounds like you have a plan then, so I'm going to leave all of the model stuff alone here.
It's more like a plan to come up with a plan.
Bear in mind we built this in one feverish 12-hour session. You're right to question our decisions :)
Every time I look at the code we wrote that day I cringe, especially when I need to use it for something new.
@dcrosta Hey :).
If you get a minute, can you clarify the motivation for moving the API's
lat
andlon
properties intoloc
on theUser
model (currently happening insidesync_user
). If there's a reason for it, I'm gonna move it onto the model, but if not, we can just get rid of it [and replace it with either nothing, or a property if you like having both available].Also, for why the
id
properties are changed to_id
on all the models, since that also adds a bit of complexity over just being able to use the API responses as we get them. Here too I think if there's reason to do so (I apologize for not knowing anything whatsoever about Mongo in case that's the reason), I'm gonna giveModel
afrom_api_response
method to do that mangling, but we can leave that out too if it isn't so necessary.