Skip to content

Commit 92b88c1

Browse files
authored
DOCSP-30634 Mapping Rule Options Drawer (#21)
* DOCSP-30634 Mapping Rule Options Drawer
1 parent 4f09b87 commit 92b88c1

File tree

8 files changed

+540
-5
lines changed

8 files changed

+540
-5
lines changed

source/diagrams/understand-diagrams.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ MongoDB's embedded data model:
197197

198198

199199
- The ``Order`` collection contains a rule that maps ``OrderLines`` as
200-
an :ref:`Embedded array <mapping-rule-embedded-array>`. The
200+
an :ref:`Embedded array <rm-embedded-array>`. The
201201
``OrderLine`` table from the relational schema is mapped as an array
202202
of objects inside the ``Order`` documents, using the foreign key
203203
relationship from the relational schema.
@@ -208,7 +208,7 @@ MongoDB's embedded data model:
208208

209209

210210
- The ``Customer`` collection contains a rule which maps ``Orders`` as
211-
an :ref:`Embedded array <mapping-rule-embedded-array>`. The ``Order``
211+
an :ref:`Embedded array <rm-embedded-array>`. The ``Order``
212212
table from the relational schema is mapped as an array of objects
213213
inside the ``Customer`` documents, using the foreign key relationship
214214
from the relational schema.
Binary file not shown.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
The blue dotted box in the MongoDB diagram pane is a visual preview of how each
2+
rule and option affect your destination data model. Using this feature,
3+
you can preview your destination data model before you run a sync job.
4+
5+
.. image:: /img/mapping-options/mappings-options-embedded-documents-preview.png
6+
:alt: Preview Mapping Options
Lines changed: 118 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,122 @@
1-
.. _mapping-rule-embedded-array:
1+
.. _rm-embedded-array:
22

33
==============
44
Embedded Array
55
==============
6+
7+
.. contents:: On this page
8+
:local:
9+
:backlinks: none
10+
:depth: 1
11+
:class: singlecol
12+
13+
The :guilabel:`Embedded array` mapping rule is an advanced mapping rule option.
14+
It must be explicitly added to a mapping model.
15+
16+
About this Task
17+
---------------
18+
19+
The :guilabel:`Embedded array` mapping rule is available if the relational
20+
table it is mapping from is on the many side of the foreign key relationship.
21+
22+
The table containing the primary key must also be mapped to a
23+
collection in the MongoDB model.
24+
25+
Behavior
26+
--------
27+
28+
Use the :guilabel:`Embedded array` mapping rule to insert the
29+
values of the child table as array elements under documents in
30+
the collection mapped to the parent table.
31+
32+
Example
33+
-------
34+
35+
This section demonstrates the relational input and
36+
the MongoDB output of the :guilabel:`Embedded array` mapping rule.
37+
38+
Embedded array
39+
~~~~~~~~~~~~~~
40+
41+
In this example:
42+
43+
- An :guilabel:`Embedded Array` mapping rule is applied to the :guilabel:`Customer` table.
44+
- The :guilabel:`Source table` is set to :guilabel:`Order`.
45+
- The :guilabel:`Prefix` is set to :guilabel:`(root)`.
46+
- The :guilabel:`Field Name` is set to :guilabel:`orders`.
47+
48+
49+
Click the tabs below to see the input and output for this example:
50+
51+
.. tabs::
52+
53+
.. tab:: Relational Input
54+
:tabid: Embedded-array-in
55+
56+
``Customer`` table:
57+
58+
.. list-table::
59+
:header-rows: 1
60+
61+
* - Id
62+
- Name
63+
- Address1
64+
- Address2
65+
- Address3
66+
* - 1
67+
- Joelynn Fawthrop
68+
- 86 Dwight Pass
69+
- Carregal
70+
- 3800-854
71+
72+
``Orders`` table:
73+
74+
.. list-table::
75+
:header-rows: 1
76+
77+
* - OrderID
78+
- CustomerID
79+
- TotalAmount
80+
- OrderStatusID
81+
* - 1
82+
- 1
83+
- 50.00
84+
- 1
85+
* - 4
86+
- 1
87+
- 500.00
88+
- 3
89+
90+
.. tab:: MongoDB Output
91+
:tabid: Embedded-array-out
92+
93+
The document in the ``Customer`` collection now has the ``Order`` details
94+
embedded as an array of objects field called ``Orders``.
95+
96+
All of the customers orders are now visible in the ``Customer`` collection
97+
as an array of nested documents.
98+
99+
.. code-block:: javascript
100+
:copyable: false
101+
:emphasize-lines: 7-19
102+
103+
{
104+
"_id": { "CustomerID": 1 },
105+
"Name": "Joelynn Fawthrop",
106+
"Address1": "86 Dwight Pass",
107+
"Address2": "Carregal",
108+
"Address3": "3800-854",
109+
"Orders":
110+
[
111+
{ "OrderID": 1,
112+
"CustomerID": 1,
113+
"TotalAmount": 50,
114+
"OrderStatusID": 1
115+
},
116+
{ "OrderID": 4,
117+
"CustomerID": 1,
118+
"TotalAmount": 500,
119+
"OrderStatusID": 1
120+
}
121+
]
122+
}

0 commit comments

Comments
 (0)