找不到任何关于与 Lithum 模型的关系的文档(使用 MongoDB)。谁能给我一些信息或给我看一个例子?
4 回答
以为您可能喜欢快速更新。
关系现在正在锂中工作,我不确定它们到底有多完整,但我相信它们以某种形式运行。查看x-relationships分支了解详情。
更新:对于任何谷歌搜索并找到这个答案的人,他们现在都处于核心并托管在 github 上。
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.
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. 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.
对于基本关系,我会使用 Id,但实际上,如果您需要在集合之间建立大量关系,您要么需要重新考虑数据的设置方式,要么只是切换到关系数据库。
当您需要建立关系时,非关系数据库是一个糟糕的选择。