www.un.org/chinese/ga/president http://www.ohchr.org。 例如,我要说的是,我有博客申请。 缩略语 他们可以这样看待:
require mongo_mapper
MongoMapper.database = test
class Post
include MongoMapper::Document
key :title
key :body
key :comments
many :comments
end
class Comment
include MongoMapper::EmbeddedDocument
key :author
key :body
end
p = Post.new(:title => Some post , :body => About something )
p.comments << Comment.new(:author => Emily , :body => A comment )
p.save
puts Post.all.map(&:inspect)
将在贵族数据库中编制一份文件,其中研究:
{ "_id" : ObjectId("4c4dcf4b712337464e000001"),
"title" : "Some post",
"body" : "About something",
"comments" : [
{
"body" : "A comment",
"author" : "Emily",
"_id" : ObjectId("4c4dcf4b712337464e000002")
}
] }
就通过MongoMapper与他们互动而言,只有MongoMapper:Document
对find
和save
等方法的答复。 缩略语 只能通过上级文件查阅。 其含义是,你只应使用<代码>MongoMapper:EmbeddedDocument,用于明显与其母体模型相配套的模型,而且只能用于母体。