Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Embedding Comments on Posts

Continue the Import Tool learning trail by embedding JSONPlaceholder comments on each DEMO_POST as a composite child stream.

This path continues Importing Users and Posts. You already have the Demo User connection, the Demo User import, and working Demo User and Demo Post streams. Here you embed comments as an array on each post instead of creating separate comment instances.

Work through each section in order from top to bottom.

Complete Importing Users and Posts first. You need published Demo User and Demo Post mappings, and at least one successful full run that created DEMO_POST instances.

Before you start

Confirm that these pieces from Importing Users and Posts are still in place:

  • Connection Demo User with Base URL https://jsonplaceholder.typicode.com

  • Import Demo User with streams Demo User and Demo Post

  • Custom entities DEMO_USER and DEMO_POST

  • Demo Post Depends on Demo User

This continuation uses GET https://jsonplaceholder.typicode.com/comments. Comments belong to posts through postId.

Add the comments array on DEMO_POST

Before you create the Demo Comment stream, add a place on each post where comments can be stored. On the DEMO_POST mixin, create a comments array field with the nested keys you want to import.

Embed as attribute and Field Mapping both need that array before they can list or target it. Add the field first, then configure the Demo Comment stream.

  1. Open DEMO_POST in Settings -> Custom Entities, then open its mixin schema.

  2. On the Fields tab, choose + and add a field with Key comments (not only a display Name).

  3. Set Type to Array and Array Type to Object. Other types do not appear in the Embed as attribute picker.

  4. Choose + inside the comments row and add nested fields. Set each nested Key to id, name, email, and body (not a generated UUID), each as Text.

  5. Save the mixin schema. If the schema already existed, confirm the new version.

DEMO_POST mixin Fields tab with comments array of object and nested id name email body
Mixin fields for `DEMO_POST` with `comments` as **Array** of **Object**, and nested **Key** values `id`, `name`, `email`, and `body`.

Creating the Demo Comment stream

Add one HTTP stream that reads /comments and writes into the same DEMO_POST target type as Demo Post.

1

Create the Demo Comment stream

On the Demo User import, choose + New stream and enter:

  • Name – Demo Comment

  • Connection – Demo User

  • Resource name – Demo Comment

  • Method – GET

  • Path – /comments

  • Records path – (response is the array)

  • Response format – JSON

  • Pagination method – None (single request)

Choose Sample endpoint to call the path once and list the fields returned for the key picker. Then set:

  • Key field – id

  • Target – emporix.customEntity

  • Target type – DEMO_POST

Save the stream. Demo Comment uses the post target type because comments are embedded on the post document.

2

Check the HTTP endpoint

On the Demo Comment stream row, choose the edit icon. Open the HTTP endpoint tab and confirm:

  • Method – GET

  • Path – /comments

  • Response format – JSON

  • Records path – (response is the array)

Choose Save if you change anything.

3

Check key resolution

Open the Demo Comment stream Key resolution tab.

Configuring composite child

On the Demo Comment stream row, open the Composite tab and choose Composite child (embedded in a parent). Set:

  • Parent stream – Demo Post

  • Linking field (this record → parent) – postId

  • Parent key field – id

  • Embed as attribute – comments. If the value is not in the list, enter it manually.

  • Child strategy – Embed (parent writes the array)

Save.

For more details, see Composite child.

Demo Comment stream Composite tab with Demo Post parent postId linking and comments embed attribute
Demo Comment as **Composite child** of Demo Post, with linking field `postId`, parent key `id`, and **Embed as attribute** `comments`.

The parent stream must run before the child. Confirm the order in Run order or on the Dependency graph tab.

Run Order dependency graph with Demo User Demo Comment and Demo Post
Dependency graph for the Demo User import. Demo Comment is a composite child linked to Demo Post; streams run so parents are available for embedding.

Mapping comment fields

1

Open Edit mapping and choose the schema

Choose Edit mapping. Choose the Target schema version that includes the comments array. If comments is missing, add it as described in Add the comments array on DEMO_POST, then switch to the new schema version.

2

Fetch a sample and map fields

Choose Fetch sample. Map each comment field Map from source or with + Add row. Choose Target Field values under comments[], for example comments[].id, comments[].name, comments[].email, and comments[].body or comments[].commentBody. Do not map onto the post-level id, title, or body.

The Composite tab attaches each comment record to the parent comments array through Embed as attribute. You do not use + Map array for this. + Map array is only for mapping a source array field to a target array field in one mapping row.

If source body and post-level body collide in the picker, rename the nested comment key to commentBody, switch Target schema to the new version, and map source body to comments[].commentBody manually.

Delete the postId mapping row if its Target Field is empty. Composite uses postId for parent linking; an incomplete row can leave Save inactive.

Save and Publish the Demo Comment mapping.

Field Mapping for Demo Comment with comment fields mapped under the DEMO_POST schema
Demo Comment Field Mapping with nested `comments[]` targets selected. Leave `postId` unmapped or remove that row; the **Composite** tab uses it for parent linking.

Running and reviewing

1

Run Full

Choose Run options and Run Full Force. Demo User and Demo Post records upsert in place, and each post receives its comments array.

Run Options dialog with Run Full and Demo User Demo Comment Demo Post selected
Run Options with **Run Full** and all three streams selected. Demo Comment shows as parent-scoped to Demo Post.
2

Review a post instance

Open a DEMO_POST instance in Custom Instances. Check that Comments shows the embedded records for that post's postId.

Composite child comments do not get their own rows in Imported Data. Review outcomes on the Demo Post stream and on the post instance itself.

Run history for Demo User import with Demo User Demo Comment and Demo Post succeeded
Run history for a successful full run. Demo Comment is a composite child, so it may show reads and skips without separate created rows. Then open a `DEMO_POST` instance to review the embedded **Comments** array.

What to do next

JSONPlaceholder has the same parent and child pattern for other resources. You can add streams later without changing the connection:

  • Albums – /albums (userId) as another standalone type that Depends on Demo User

  • Photos – /photos (albumId) as a composite child embedded on albums

  • Todos – /todos (userId) as a standalone type that Depends on Demo User

Troubleshooting

Problem
What to do

Embed as attribute shows no results

Add a comments field on the DEMO_POST mixin with Type Array and Array Type Object, Key exactly comments, then save and reopen the Composite tab.

comments is missing from Field Mapping

Add the array on the DEMO_POST mixin with nested Key values id, name, email, and body, save a new schema version, then switch Target schema.

Nested fields show UUID keys

Edit the mixin and set each nested Key to id, name, email, or body. Display Name alone is not enough for mapping.

Target Field shows only parent post fields

Confirm Embed as attribute is comments, the schema version includes the nested keys, and you reopened Edit mapping after saving. Do not map comment fields onto post-level id or body.

Save, Publish, or Map from source stay inactive after a schema change

Delete any row with an empty Target Field (often postId). Refresh the browser, open Edit mapping again, and select the latest Target schema version.

Key field shows ID with a schema warning

Change Key field to id, then Save.

Key field picker is empty

Choose Sample endpoint after you set Path and Records path, then select id from the returned fields.

Comments array is empty after a full run

Confirm Demo Comment is Composite child of Demo Post, linking field postId, and the Demo Comment mapping is published. Check Run order.

Comments fails with embedAttribute / "schema attribute with no name"

Open the Demo Comment Composite tab, set Embed as attribute to comments, choose Save, then run again. An empty embed attribute causes this failure.

Imported Data has no comment rows

Expected for composite children. Open a DEMO_POST instance and review the embedded Comments array.

Last updated

Was this helpful?