Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Edits to Added documentation for sub-JSON accessing feature in Mongo … #6363

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading