Skip to content

Commit 62f5eb6

Browse files
committed
reorder mapping steps, add subset pattern for book reviews
1 parent 125a318 commit 62f5eb6

10 files changed

+26
-1
lines changed
File renamed without changes.
File renamed without changes.

docs/80-Edit Mapping Rules/40-add-mapping-books-authors.mdx renamed to docs/80-Edit Mapping Rules/30-add-mapping-books-authors.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import Screenshot from "@site/src/components/Screenshot";
33
# 👐 Add mapping to books collection (from authors table)
44

55
We want to modify the MongoDB schema so that each book contains an array of its authors.
6-
In this step we will embed the book details into the empty array from the join tabe.
6+
In this step we will embed the book details into the empty array from the join table.
77

88
- On the MongoDB diagram view, click the `books` collection
99
- On the relational mappings list on the right, click `+ Add`
File renamed without changes.
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import Screenshot from "@site/src/components/Screenshot";
2+
3+
# 👐 Add mapping to books collection (from reviews table)
4+
5+
We want to modify the MongoDB schema so that each book contains an array of its latest three reviews.
6+
This is actually an implementation of the [Subset Pattern](https://www.mongodb.com/blog/post/building-with-patterns-the-subset-pattern).
7+
8+
In this step we will embed the book details into the empty array from the join table.
9+
10+
- On the MongoDB diagram view, click the `books` collection
11+
- On the relational mappings list on the right, click `+ Add`
12+
- Select `Embedded array`
13+
- Select `reviews` as Source table
14+
- In the advanced settings, check 'Add array conditions`
15+
- In `Sort by and order` option, select 'timestamp' and toggle the order to descending
16+
- Set `Limit number of rows` to `3`
17+
- Uncheck the `bookId` and leave the rest of the fields checked
18+
- Click `Save and close`
19+
20+
Limitations:
21+
- Continuous Migration Mode will not support this transformation
22+
- You will not be able to enable Data Verification when you create the Migration Job.
23+
24+
<Screenshot url="https://www.mongodb.com/products/tools/relational-migrator" src="img/150-image-002.png" alt="Screenshot of the connect modal" />
25+
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

static/img/150-image-002.png

666 KB
Loading

0 commit comments

Comments
 (0)