> ## Documentation Index
> Fetch the complete documentation index at: https://docs.bringits.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Insert To Children

> Map specific parent attributes to child objects using JSONPath queries

The Insert To Children command (Command Type: 1013) maps specific parent attributes to child objects using JSONPath queries and a key mapping configuration.

## Overview

The Insert To Children command provides functionality for:

* Selecting parent objects with a JSONPath query
* Selecting child objects within each parent with a JSONPath query
* Copying specific parent attributes into each child object using mapping rules

## Command Type

**Command Type ID:** 1013

## Parameters

| Parameter       | Type                | Description                                                     | Required |
| --------------- | ------------------- | --------------------------------------------------------------- | -------- |
| **query**       | string              | JSONPath query to select parent objects from the data attribute | Yes      |
| **keyChildren** | string              | JSONPath query to select child objects from each parent         | Yes      |
| **mapping**     | Array of KeyMapping | Defines how parent attributes are copied to child objects       | Yes      |

### KeyMapping

| Field    | Type   | Description                                                  | Required |
| -------- | ------ | ------------------------------------------------------------ | -------- |
| **to**   | string | The new key to which the extracted value will be assigned    | Yes      |
| **from** | string | A JSONPath query string to extract the value from the parent | No       |

## Usage Examples

### Insert Event Fields into Markets

```json theme={null}
{
  "command": "insert-to-children",
  "params": {
    "query": "$.events[*]",
    "keyChildren": "$.markets[*]",
    "mapping": [
      { "from": "$.id", "to": "eventId" },
      { "from": "$.startTime", "to": "eventStartTime" }
    ]
  }
}
```

### Insert League Info into Fixtures

```json theme={null}
{
  "command": "insert-to-children",
  "params": {
    "query": "$.leagues[*]",
    "keyChildren": "$.fixtures[*]",
    "mapping": [
      { "from": "$.leagueId", "to": "leagueId" },
      { "from": "$.leagueName", "to": "leagueName" },
      { "from": "$.sportId", "to": "sportId" }
    ]
  }
}
```

## Common Use Cases

* **Hierarchy Flattening**: Propagate parent identifiers into nested children
* **Data Enrichment**: Attach parent context to child records for downstream processing
* **Denormalization**: Combine parent and child fields into flat records for sink commands

## Related Commands

* [Insert To Children By Query](/stream/commands/parse/insert-to-children-by-query) - Insert a single field using a query
* [Insert To Children By Query List](/stream/commands/parse/insert-to-children-by-query-list) - Insert multiple fields at once
* [Key Mapping](/stream/commands/parse/key-mapping) - Remap object keys
