[英]mongodb ORMs without full schema?
I'm frequently finding myself with one foot in POJO land, and one foot in JSON land. 我经常发现自己一只脚踩在POJO领域,另一只脚踩在JSON领域。 I want my Mongo documents that have a formal, but partially specified schema.
我希望我的Mongo文档具有正式的但部分指定的架构。 POJO land assumes a fully specified schema.
POJO地域采用完全指定的架构。 JSON land provides no contraints.
JSON land不提供任何约束。
As an example, suppose I download a bunch of user data from facebook, it arrives as a JSON blob. 例如,假设我从facebook下载了一堆用户数据,它以JSON blob的形式到达。 Facebook essentially owns this structure and its madness to try to map it into an internal POJO structure - if one days FB changes this, our server break and we stop collecting this data, what the right thing to do is to store it verbatim.
Facebook本质上拥有这种结构,并且疯狂地试图将其映射到内部POJO结构中-如果有一天FB改变了这种情况,我们的服务器中断了,我们停止了收集数据,那么正确的做法就是逐字存储它。
What I want is to specify rules and contraints about what goes into all my databases to the extent possible and the schema is well defined : 我想要的是指定规则和约束, 以尽可能地限制我所有数据库中所包含的内容,并明确定义该模式 :
I'm half way through building such a thing. 我已经完成了一半这样的事情。 But though it would be a good idea to see if existing project exist that allow document constraints to be specified.
但是,最好查看是否存在允许指定文档约束的现有项目。
What you are searching for is called a object-document-mapper or ODM (the document-database analogue to an ORM, or object-relational mapper in SQL databases). 您要搜索的内容称为对象文档映射器或ODM(类似于ORM的文档数据库,或SQL数据库中的对象关系映射器)。
There are different wrappers like this available for Java, like Morphia or Spring-MongoDB . 有类似Java的不同包装器,如Morphia或Spring-MongoDB 。 A longer list can be found on Java Language Center on mongodb.org .
可以在mongodb.org的Java语言中心上找到更长的列表。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.