简体   繁体   English

MongoDB & Java DBRef 使用

[英]MongoDB & Java DBRef Usage

So let's say I have a patient document in MongoDB.因此,假设我在 MongoDB 中有一份患者文件。 It has things such as first name, last name, etc… I am trying to add to the current document a list of providers (which is another collection, by DBRef, as I am using POJO. How would I append multiple providers in Java to the document?它有名字,姓氏等内容......我正在尝试向当前文档添加一个提供者列表(这是另一个集合,由 DBRef 提供,因为我正在使用 POJO。我将如何 append Java 中的多个提供者到文件?

One way to do this is by just appending to a document like this:一种方法是仅附加到这样的文档:

Document doc = new Document("user", userObject).append("providers", providersObject); Document doc = new Document("user", userObject).append("providers", providersObject);

providersObject would be your list of providers. providersObject 将是您的提供者列表。

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

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