简体   繁体   English

如何为DBRef数组创建字段

[英]how to create a field for array of DBRef

I'm new to MongoDB. 我是MongoDB的新手。 In my java code, I have to define a Document. 在我的Java代码中,我必须定义一个Document。 One of the fields in this Document has to contain an array of DBRef to other Document. 本文档中的一个字段必须包含到其他文档的DBRef数组。 How can I create an array of customers? 如何创建一系列客户? How can it be done? 如何做呢? what are the alternatives? 有哪些选择?

@DBRef
private Customer custId;

Thanks, Eyal. 谢谢,Eyal。

class DBRef {
    public static void main {String args[]) {
    int customers[][] = new int [7][];
    customers[0] = new int p[];
    customers[1] = new int p[];
    customers[2] = new int p[];
    customers[3] = new int p[];
    customers[4] = new int p[];
    customers[5] = new int p[];
    customers[6] = new int p[];

    int i, j;

You would want to add some data to the Array. 您可能想向阵列添加一些数据。 Arrays is a collection of variables of the same type, referred to by a common name. 数组是相同类型的变量的集合,用一个通用名称引用。 They can be one or more dimensions in java. 它们可以是Java中的一个或多个维度。 They are use to group together related variables. 它们用于将相关变量分组在一起。 For example a list of Stock price averages or a list of baseball "sports" stats. 例如,股票平均价格列表或棒球“体育”统计信息列表。 The easy ones to learn are 2D Arrays and the basic Array. 容易学习的是2D数组和基本数组。

for statement 声明

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

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