简体   繁体   English

与锂模型的关系

[英]Relationships with Lithium models

Can't find any documentation on relationships with Lithum models (using MongoDB). 找不到与Lithum模型关系的任何文档(使用MongoDB)。 Could anyone point me to some info or show me an example? 谁能指点我一些信息或给我一个例子?

Thought you might like a quick update. 以为您可能想要快速更新。

Relationships are being worked into Lithium right now, I'm not sure exactly how complete they are but I believe they are operational in some form. 目前正在与Lithium建立关系,我不确定它们究竟有多完整,但我相信它们在某种形式下可以运作。 Check out the x-relationships branch for details. 查看x-relationships分支了解详细信息。

UPDATE: For anyone Google-ing and finding this answer they are now in the core and hosted on github. 更新:对于任何人谷歌和找到这个答案他们现在在核心并托管在github上。

The lithium relationship work has been released with 0.10 . 锂合金关系工作已经以0.10发布 There's the beginnings of documentation in the manual , though that's not live on the lithium site yet. 有一个在文档的开始手动 ,虽然这不是在锂位置生活呢。

For basic relationships I would use the Ids, but realistically if you need to do a lot of relationships between collections you either need to rethink how your data is set up, or just switch to a relational database. 对于基本关系,我会使用ID,但实际上如果你需要在集合之间做很多关系,你需要重新思考数据的设置方式,或者只是切换到关系数据库。

Non-relational databases are a poor choice when you need to have relationships. 当您需要建立关系时,非关系数据库是一个糟糕的选择。

You can use Doctrine 2 or another ORM for using relationships in Lithium with a relational database, but since Lithium is very much Mongo/Couch DB slanted in its approach, the question you have is less about Lithium and more about the NoSql approach that it is encouraging. 您可以使用Doctrine 2或其他ORM在Lithium中使用关系数据库中的关系,但由于Lithium在其方法中倾向于Mongo / Couch DB,所以您的问题不是关于Lithium,而是关于NoSql方法的更多信息。令人鼓舞。

BTW I think relationships are not yet officially supported in Lithium, but NoSql have their own methods for mostly not needing them - or not needing them as much by nesting data in JSON like syntax. 顺便说一下,我认为Lithium尚未正式支持关系,但是NoSql有自己的方法,大部分都不需要它们 - 或者通过在JSON中嵌套数据就像语法一样不需要它们。 But I think this is one feature that looks like it will be coming in 1.0, expect a blog post on it fairly soon. 但我认为这是一个看起来会出现在1.0中的功能,期待很快发布一篇博文。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM