ShelbyTV / shelby_gt

Rails API services for Shelby GT
2 stars 0 forks source link

Get rid of long key names for GT embedded documents #66

Open markerrj opened 12 years ago

markerrj commented 12 years ago

currently in models like conversation.rb, we have this:

many :messages

but that results in the mongo documents having the full string "messages" as their key.

db.conversations.find( { "messages" : { $exists : true } } )

attr is not currently implemented in mongo mapper for embedded documents. but one way around this that works for video recommendations is:

key :recs, Array, :typecast => 'Recommendation', :abbr => :r many :recommendations, :in => :recs

we should consider doing this on all the embedded documents in GT, but we'd have to fix all the current keys in mongo:

egrep -Er "^[[:space:]]*many" app/models/

app/models/conversation.rb: many :messages app/models/roll.rb: many :frames, :foreign_key => :a app/models/roll.rb: many :following_users app/models/user.rb: many :roll_followings app/models/user.rb: many :authentications app/models/video.rb: many :frames, :foreign_key => :b app/models/video.rb: many :recommendations, :in => :recs