开发者

Define Rails Model Persistent Attributes in Model File

开发者 https://www.devze.com 2022-12-29 13:53 出处:网络
I recently played with MongoDB in Rails using Mongoid. I like the ability to define attributes for models within the model file (as opposed to in migrations):

I recently played with MongoDB in Rails using Mongoid. I like the ability to define attributes for models within the model file (as opposed to in migrations):

class Person
  include Mongoid::Document
  field :name, :type => String
  field :birthday, :type => Date
end

For projects that cannot use a schema-less database, does a similar feature exist? Any gems or plugins that generate sche开发者_JAVA百科mas from a similar syntax would be greatly appreciated.

Thanks.


I think both MongoMapper and Mongoid took their ideas about this from Datamapper which also support those SQL database.

0

精彩评论

暂无评论...
验证码 换一张
取 消