Skip to content

Commit

Permalink
Edits to Added documentation for sub-JSON accessing feature in Mongo …
Browse files Browse the repository at this point in the history
…FDW Key Features #6350
  • Loading branch information
ebgitelman committed Dec 18, 2024
1 parent 6d3e3ec commit c0d7b1f
Showing 1 changed file with 8 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ These are the key features of the MongoDB Foreign Data Wrapper.

## Writable FDW

The MongoDB Foreign Data Wrapper lets you modify data on a MongoDB server. You can insert, update, and delete data in the remote MongoDB collections by inserting, updating and deleting data locally in foreign tables.
The MongoDB Foreign Data Wrapper lets you modify data on a MongoDB server. You can insert, update, and delete data in the remote MongoDB collections by inserting, updating, and deleting data locally in foreign tables.

For more information, see:

Expand Down Expand Up @@ -72,7 +72,7 @@ You can retrieve all available fields in a collection residing in MongoDB Foreig
{ "_id" : ObjectId("58a1ebbaf543ec0b9054585a"), "warehouse_id" : 2, "warehouse_name" : "Laptop", "warehouse_created" : ISODate("2015-11-11T08:13:10Z") }
```

Steps for retrieving the document:
To retrieve the document:

1. Create a foreign table with a column name `__doc`. The type of the column can be json, jsonb, text, or varchar.

Expand All @@ -86,7 +86,7 @@ Steps for retrieving the document:
SELECT * FROM test_json ORDER BY __doc::text COLLATE "C";
```

The output:
The following is the output:

```sql
edb=#SELECT * FROM test_json ORDER BY __doc::text COLLATE "C";
Expand All @@ -99,9 +99,9 @@ Steps for retrieving the document:

## Accessing nested fields

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.
MongoDB Foreign Data Wrapper allows you to access individual fields in nested JSON documents by mapping the nested structure to columns in a foreign table.
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.
You can retrieve these fields from a collection as shown in the following example:
You can retrieve these fields from a collection as shown in the following example.

### Example

Expand All @@ -120,9 +120,9 @@ db1> db.test_sub_json.find()
]
```

Steps for retrieving sub-fields from the document:
To retrieve subfields from the document:

1. Create a foreign table. To access a sub-field use the dot (".") in the column name as shown below:
1. Create a foreign table. To access a subfield, use the dot (".") in the column name:

```sql
CREATE FOREIGN TABLE ft_nested_json_test(
Expand All @@ -135,7 +135,7 @@ Steps for retrieving sub-fields from the document:
OPTIONS (database 'db1', collection 'test_sub_json');
```

1. Retrieve the document with sub-fields:
1. Retrieve the document with subfields:

```sql
SELECT * FROM ft_nested_json_test;
Expand Down

0 comments on commit c0d7b1f

Please sign in to comment.