README.md in mosql-0.1.2 vs README.md in mosql-0.2.0
- old
+ new
@@ -51,12 +51,19 @@
mongodb:
blog_posts:
:columns:
- - _id: TEXT
- - author: TEXT
+ - id:
+ :source: _id
+ :type: TEXT
+ - author_name:
+ :source: author.name
+ :type: TEXT
+ - author_bio:
+ :source: author.bio
+ :type: TEXT
- title: TEXT
- created: DOUBLE PRECISION
:meta:
:table: blog_posts
:extra_props: true
@@ -65,19 +72,45 @@
mapping
<Mongo DB name> -> { <Mongo Collection Name> -> <Collection Definition> }
Where a `<Collection Definition>` is a hash with `:columns` and
-`:meta` fields. `:columns` is a list of one-element hashes, mapping
-field-name to SQL type. It is required to include at least an `_id`
-mapping. `:meta` contains metadata about this collection/table. It is
+`:meta` fields.
+
+`:columns` is a list of hashes mapping SQL column names to an hash
+describing that column. This hash may contain the following fields:
+
+ * `:source`: The name of the attribute inside of MongoDB.
+ * `:type`: (Mandatory) The SQL type.
+
+
+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
+and the name of the destination column. You can see this shorthand for
+the `title` and `created` attributes, above.
+
+Every defined collection must include a mapping for the `_id`
+attribute.
+
+`:meta` contains metadata about this collection/table. It is
required to include at least `:table`, naming the SQL table this
collection will be mapped to. `extra_props` determines the handling of
unknown fields in MongoDB objects -- more about that later.
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
is: