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

Commit

Permalink
Add some documentation on dot-notation in collection maps.
Browse files Browse the repository at this point in the history
  • Loading branch information
nelhage committed Apr 12, 2013
1 parent 9c31738 commit 2661ad4
Showing 1 changed file with 16 additions and 5 deletions.
21 changes: 16 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,11 @@ types. An example collection map might be:
- id:
:source: _id
:type: TEXT
- author:
:source: author
- author_name:
:source: author.name
:type: TEXT
- author_bio:
:source: author.bio
:type: TEXT
- title: TEXT
- created: DOUBLE PRECISION
Expand All @@ -79,9 +82,15 @@ describing that column. This hash may contain the following fields:
* `:source`: The name of the attribute inside of MongoDB.
* `:type`: (Mandatory) The SQL type.

This syntax allows to rename MongoDB's attributes during the
import. For example the MonogDB `_id` attribute will be transferred to
a SQL column named `id`.

Use of the `:source` attribute allows for renaming attributes, and
extracting elements of a nested hash using MongoDB's
[dot notation][dot-notation]. In the above example, the `name` and
`bio` fields of the `author` sub-document will be expanded, and the
MongoDB `_id` field will be mapped to an SQL `id` column.

At present, MoSQL does not support using the dot notation to access
elements inside arrays.

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

[dot-notation]: http://docs.mongodb.org/manual/core/document/#dot-notation

## Usage

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

0 comments on commit 2661ad4

Please sign in to comment.