You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
MongoDB Foreign Data Wrapper allows you to access individual fields within nested JSON documents by mapping the nested structure to columns in a foreign table.
103
+
This works by mapping the nested structure of the MongoDB document to relational columns in the foreign table definition, using dot notation (key2.subkey21) to reference nested fields.
104
+
You can retrieve these fields from a collection as shown in the following example:
105
+
106
+
### Example
107
+
108
+
```text
109
+
db1> db.test_sub_json.find()
110
+
[
111
+
{
112
+
_id: ObjectId('658040214890799d6e0173d0'),
113
+
key1: 'hello',
114
+
key2: {
115
+
subkey21: 'hello-sub1',
116
+
subkey22: 'hello-sub2',
117
+
subtstmp: ISODate('2022-12-16T19:16:17.801Z')
118
+
}
119
+
}
120
+
]
121
+
```
122
+
123
+
Steps for retrieving sub-fields from the document:
124
+
125
+
1. Create a foreign table. To access a sub-field use the dot (".") in the column name as shown below:
0 commit comments