Skip to content
This repository was archived by the owner on Dec 22, 2020. It is now read-only.

Commit 2661ad4

Browse files
committed
Add some documentation on dot-notation in collection maps.
1 parent 9c31738 commit 2661ad4

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

README.md

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,11 @@ types. An example collection map might be:
5656
- id:
5757
:source: _id
5858
:type: TEXT
59-
- author:
60-
:source: author
59+
- author_name:
60+
:source: author.name
61+
:type: TEXT
62+
- author_bio:
63+
:source: author.bio
6164
:type: TEXT
6265
- title: TEXT
6366
- created: DOUBLE PRECISION
@@ -79,9 +82,15 @@ describing that column. This hash may contain the following fields:
7982
* `:source`: The name of the attribute inside of MongoDB.
8083
* `:type`: (Mandatory) The SQL type.
8184

82-
This syntax allows to rename MongoDB's attributes during the
83-
import. For example the MonogDB `_id` attribute will be transferred to
84-
a SQL column named `id`.
85+
86+
Use of the `:source` attribute allows for renaming attributes, and
87+
extracting elements of a nested hash using MongoDB's
88+
[dot notation][dot-notation]. In the above example, the `name` and
89+
`bio` fields of the `author` sub-document will be expanded, and the
90+
MongoDB `_id` field will be mapped to an SQL `id` column.
91+
92+
At present, MoSQL does not support using the dot notation to access
93+
elements inside arrays.
8594

8695
As a shorthand, you can specify a one-elment hash of the form `name:
8796
TYPE`, in which case `name` will be used for both the source attribute
@@ -100,6 +109,8 @@ By default, `mosql` looks for a collection map in a file named
100109
`collections.yml` in your current working directory, but you can
101110
specify a different one with `-c` or `--collections`.
102111

112+
[dot-notation]: http://docs.mongodb.org/manual/core/document/#dot-notation
113+
103114
## Usage
104115

105116
Once you have a collection map. MoSQL usage is easy. The basic form

0 commit comments

Comments
 (0)