Bottom-level Array Indexing

The Simba MongoDB JDBC Driver supports bottom-level array indexing, by inserting data at the index point that is next in the sequence.

For example, a MongoDB database contains a table named Test, which has a single document with the following content:

{

_id : 2000,

"Array" : [ 0,

{

"BottomLevelArray" : [

{

"col" : "Federer"

}

]

}

]

}

The connector expands this array into the following virtual table named Test_Array_BottomLevelArray:

_id Test_Array_dim1_idx Test_Array_BottomLevelArray_dim1_idx col

2000

1

0

Federer

In this example, you want to append the value "Nadal" to the end of the array (after "Federer"), so that the resulting virtual table looks like this:

_id Test_Array_dim1_idx Test_Array_BottomLevelArray_dim1_idx col

2000

1

0

Federer

2000

1

1

Nadal

You can execute any of the following statements:

INSERT INTO Test_Array_BottomLevelArray_dim1_idx values (2000, 1, 'Nadal')

INSERT INTO Test_Array_BottomLevelArray_dim1_idx values (2000, 1, -1, 'Nadal')

INSERT INTO Test_Array_BottomLevelArray_dim1_idx values (2000, 1, 1, 'Nadal')

Note:

  • Even though statements that contain the bottom-level index value are supported, it is still recommended that you omit this value, as it is not required.
  • In all cases, you must specify the upper-level index value. This indicates which array the connector should insert the value in.