Mapping selected fields
Available Fields, shown in
Figure 4‑42, displays fields and subordinate documents found by searching documents in a MongoDB collection. A subordinate document can, in turn, contain fields and other subordinate documents. For example, in
Figure 4‑42, Available Fields shows the fields _id and name and the subordinate document nestedDocs[]. The subordinate document nestedDocs[] contains the field text and the subordinate document follower. In Selected Fields, fields in subordinate documents are identified using dot notation, for example nestedDocs[].text and nestedDocs[].follower.followed. When a subordinate document and its fields are both selected, only the selected fields are included in the subordinate document.
A field can be of type Array, and can contain multiple scalar values or subordinate documents. By default, scalar values in an array field are concatenated into a single String value in JSON expression format in a result set column, for example [1.0, 2.0, 3.0]. The field values in each subordinate document in an array field are also, by default, concatenated into a single String value in a result set column, for example
[{"followed":true,"ratings":[1.0,2.0,3.0]},{"followed":true,"ratings":[1.0,2.0,3.0]}]
You can specify one or more array projection operators, such as $slice and $elemMatch, to project elements from an array in the result set. For example, you can use $slice to project elements from the zipcodes collection:
{ city: 1, loc: {$slice : 1}, state : true, _id : false }
Specify array projection operators in Selected Fields on the Property Binding page in the Data Set Editor. Make sure that the field names projected in the result set match the output column names in the BIRT data set. Alternatively, you can flatten subordinate documents by setting the Flatten nested collections runtime connection property to true.
Table 4‑2 shows the native data type to ODA data type mapping for MongoDB.
Table 4‑2 Native data type to ODA data type mapping for MongoDB
Native data type | Native data type value | ODA data type |
Number | 1 | Double |
String | 2 | String |
Object | 3 | JavaObject |
Array | 4 | JavaObject |
Binary | 5 | Blob |
Object id | 7 | String |
Boolean | 8 | Boolean |
Date | 9 | Date |
Null | 10 | String |
Regular expression | 11 | String |
JavaScript | 13 | String |
Symbol | 14 | String |
JavaScript with scope | 15 | String |
32-bit integer | 16 | Integer |
Timestamp | 17 | Timestamp |
64-bit integer | 18 | String |
Min key | 255 | String |
Max key | 127 | String |