ruby on rails - Defining a different primary key in Mongomapper -


i defining primary key in mongomapper.

class b   key :_id, string   key :externalid, string end 

the problem add new record in b, appears need explicity specify _id, when defined in external id

b.new(:_id=>"123", :external_id=>"123 ) 

that not quite make sense. there should way specify externalid primary key, no?

if problem bson::objectid, created plugin can you, plugin adds auto incremented id mongomapper documents

https://github.com/phstc/mongomapper_id2

movie = movie.create(:title => 'the simpsons movie') movie.id # bson::objectid('4d1d150d30f2246bc6000001') # here mongomapper_id2 movie.id2 # 1  movie2 = movie.create(:title => 'pirates of silicon valley') movie2.id2 # 2 

Comments

Popular posts from this blog

Add email recipient to all new Trac tickets -

400 Bad Request on Apache/PHP AddHandler wrapper -

php - Change action and image src url's with jQuery -