DataMapper:将模型放入模型中
在关联的DataMapper文档中,我找到了一个示例,他们将模型放入模型中,例如
1 class Person
2
3 class Link
4
5 include DataMapper::Resource
6
7 storage_names[:default] = 'people_links'
8
9 # the person who is following someone
10 belongs_to :follower, 'Person', :key => true
11
12 # the person who is followed by someone
13 belongs_to :followed, 'Person', :key => true
14
15 end
16
17 include DataMapper::Resource
18
19 property :id, Serial
20 property :name, String, :required => true
21 ...
......它对您返回的结果有任何影响还是只是另一种符号或格式?
预先感谢,鲁弗斯
In the DataMapper documentation for associations I found an example where they put a model into a model like...
1 class Person
2
3 class Link
4
5 include DataMapper::Resource
6
7 storage_names[:default] = 'people_links'
8
9 # the person who is following someone
10 belongs_to :follower, 'Person', :key => true
11
12 # the person who is followed by someone
13 belongs_to :followed, 'Person', :key => true
14
15 end
16
17 include DataMapper::Resource
18
19 property :id, Serial
20 property :name, String, :required => true
21 ...
Does it have any influence on the result you get back or is it just another notation or format?
Thanks in advance, rufus
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
不,它对结果没有任何影响。
如果将模型放在命名空间中,它会反映在存储名称中。这就是为什么在上面的示例中您会在 Link 模型中看到“storage_names[:default] = 'people_links'”,因为该模型位于 Person 命名空间内,这反映在“people_links”表名称中。
No, it doesn't have any influence on the result.
If you put your models in a namespace it will reflect in storage names though. That's why in the example above you see "storage_names[:default] = 'people_links'" in Link model, because that model is inside Person namespace, which is reflected in "people_links" table name.