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

# Property types

| Property                | Description                                                                                                                                                                                                   |
| ----------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [String](#string)       | Basic string mapping. <br /><br />Accepts the following fields: `type` `value` `default` <br /><br />Note: `type` and `value` are required if you aren't using the shorthand - e.g. `"title": "{p.headline}"` |
| [Number](#number)       | Basic number or integer mapping. <br /><br />Required fields: `type` `value` <br /><br />Optional fields: `default` `precision`                                                                               |
| [Boolean](#boolean)     | Basic boolean mapping. <br /><br />Required fields: `type` `value` <br /><br />Optional fields: `default`                                                                                                     |
| [Array](#array)         | Mapping of an array, defining the input to iterate and the items definition. <br /><br />Required fields: `type` `input` `items` <br /><br />Optional fields: `var`                                           |
| [Object](#object)       | Mapping of an object. <br /><br />Required fields: `type` `properties`                                                                                                                                        |
| [Reference](#reference) | Referencing another schema. <br /><br /> Required fields: `type` `alias` - use `id` **OR** `originId` <br /><br />Optional fields: `source`                                                                   |
| [Partial](#partial)     | Referencing a partial schema to map the data into. <br /><br />Required fields: `type` `input` `alias`                                                                                                        |
| [Dynamic](#dynamic)     | Dynamic mapping using the [path selector](./path-selector). <br /><br />Required fields: `*`                                                                                                                  |

<Tip>
  There is no `Date` property type. But if you ingest your dates as strings in the following format `yyyy-MM-ddTHH:mm:ss`, you can still sort by date and the value can easily be parsed to Date on the client in JavaScript and other languages.
</Tip>

## string

Basic string mapping.

Since string is the most commonly used property type you can access it without writing the `type` and `value` property. This is meant as syntactic sugar making it easier and quicker to work with.

### Fields

| Property  | Required? | Description                                                     |
| --------- | --------- | --------------------------------------------------------------- |
| `type`    | **Yes**   | The property type - here `string`                               |
| `value`   | **Yes**   | The value of the property                                       |
| `default` | No        | The default value is used if `value` is null or an empty string |

### Examples

```json title="Property type: string" theme={null}
"title": "{p.headline}"
```

```json title="Property type: string with value and default" theme={null}
"title": {
  "type": "string",
  "value": "{p.headline}",
  "default": "Unknown title"
}
```

***

## number

Basic number or integer mapping.

<Info>
  The size of the number is limited to the size of a [C# double](https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/builtin-types/floating-point-numeric-types#characteristics-of-the-floating-point-types).
</Info>

### Fields

| Property    | Required? | Description                                                                                                                                  |
| ----------- | --------- | -------------------------------------------------------------------------------------------------------------------------------------------- |
| `type`      | **Yes**   | The property type - here `number`                                                                                                            |
| `value`     | **Yes**   | The value of the property                                                                                                                    |
| `default`   | No        | The default value is used if `value` is null or can be parsed as a number                                                                    |
| `precision` | No        | Rounds a decimal value to a specified number of fractional digits, and rounds midpoint values to the nearest even number. Default value is 0 |

### Examples

```json title="Property type: number" theme={null}
"stock": {
  "type": "number",
  "value": "{p.inventoryQuantity}"
}
```

***

## boolean

Basic boolean mapping.

### Fields

| Property  | Required? | Description                                                                |
| --------- | --------- | -------------------------------------------------------------------------- |
| `type`    | **Yes**   | The property type - here `boolean`                                         |
| `value`   | **Yes**   | The value of the property                                                  |
| `default` | No        | The default value is used if `value` is null or can be parsed as a boolean |

### Examples

```json title="Property type: boolean" theme={null}
"isPublished": {
  "type": "boolean",
  "value": "{p.published}",
  "default": true
}
```

***

## array

Mapping of an array, defining the input to iterate and the items definition.

Array property type is designed for working with collections.

### Fields

| Property | Required? | Description                                                                                                        |
| -------- | --------- | ------------------------------------------------------------------------------------------------------------------ |
| `type`   | **Yes**   | property type - here `array`                                                                                       |
| `input`  | **Yes**   | States input, where to retrieve items collection to work with from. Support input types: `string` `$exp` `$lookup` |
| `items`  | No        | Used for mapping results.                                                                                          |
| `var`    | No        | Collection iteration variable name. Default value is - `item`.                                                     |

### `string` type

A simple example showing how to use a `string` type in `items`.

```json title="string simple example" theme={null}
"categories": {
  "type": "array",
  "input": "{p.categories}",
  "items": {
    "type": "string",
    "value": "{item}"
  }
},
```

### `$exp` input

With expression input, you can reference the desired property on the source entity that is an array.

```json title="$exp input" theme={null}
"tabs": {
  "type": "array",
  "input": "{p.tabs}",
  "var": "tab",
  "items": {
    "type": "object",
    "properties": {
      "title": "{tab.title}",
      "content": "{tab.content}"
    }
  }
}
```

### `$path` input

With path input, you can select the desired items on the source entity using the [path selector](./path-selector).

```json title="$path input" theme={null}
"tabs": {
  "type": "array",
  "input": {
    "$path": "p.tabs[*]"
  },
  "var": "tab",
  "items": {
    "type": "object",
    "properties": {
      "title": "{tab.title}",
      "content": "{tab.content}"
    }
  }
}
```

Filter items:

```json title="$path input with filter" theme={null}
"tabs": {
  "type": "array",
  "input": {
    "$path": "p.tabs[?(@.display==true)]"
  },
  "var": "tab",
  "items": {
    "type": "object",
    "properties": {
      "title": "{tab.title}",
      "content": "{tab.content}"
    }
  }
}
```

### `$lookup` input

Lookup input comparing to \$exp allows you to define query-like and criteria match source entities lookup conditions.

#### `$lookup` with single property value match

| Property             | Required? | Description                                                                                                                                                                                                                        |
| -------------------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| operator             | **Yes**   | The operator for the lookup. Supported operators: `equals` `contains`                                                                                                                                                              |
| sourceEntityProperty | **Yes**   | The property to match the value on                                                                                                                                                                                                 |
| matchValue           | **Yes**   | The value to match the sourceEntityProperty                                                                                                                                                                                        |
| sourceEntityType     | No        | Type of source entity to use for lookup. Default value is include all entity types available: `*`                                                                                                                                  |
| orderBy              | No        | Allows you to specify your desired sorting order                                                                                                                                                                                   |
| top                  | No        | Allows limiting the size of items collection. Can be a number, a number as a text, or an expression.                                                                                                                               |
| source               | No        | Allows you to define a different source as the property. The `source` should be equal to the desired source group alias, where you want to look for source entities.<br /><br /> If not defined, it uses the current source group. |

```json title="$lookup with a single property" theme={null}
"navigationItems": {
   "type": "array",
   "input": {
      "$lookup": {
          "operator": "equals",
          "sourceEntityType": "*",
          "sourceEntityProperty": "originParentId",
          "matchValue": "{originId}",
          "orderBy": {
            "property": "properties.metaData.sortOrder",
            "sort": "asc"
          },
          "top": 5
      }
   },
   "items": {
      "type": "reference",
      "id": "{input.id}",
      "alias": "NavigationItem"
   }
}
```

#### `$lookup` with filter

Particular lookup filter type allows you to be more flexible with your matching criteria.

| Property | Required? | Description                                                                                                                                                                                                                        |
| -------- | --------- | ---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| filter   | **Yes**   | Your filtering criteria. [See list of filter examples](/enterspeed/reference/filter-expressions)                                                                                                                                   |
| orderBy  | No        | Allows you to specify your desired sorting order                                                                                                                                                                                   |
| top      | No        | Allows limiting the size of items collection. Can be a number, a number as a text, or an expression.                                                                                                                               |
| source   | No        | Allows you to define a different source as the property. The `source` should be equal to the desired source group alias, where you want to look for source entities.<br /><br /> If not defined, it uses the current source group. |

### Additional

Arrays have some additional properties available:

* `root`
  For schemas it will contain the source entity and for partial schemas the input.
  It is possible to access everything from the source entity like `root.originId` or `root.properties.headline`.
  All property values in `items` that supports expressions can access `root`.

  ```json theme={null}
  "tabs": {
    "type": "array",
    "input": "{p.tabs}",
    "var": "tab",
    "items": {
      "type": "object",
      "properties": {
        "title": "{root.p.headline}: {tab.title}",
        "content": "{tab.content}"
      }
    }
  }
  ```

* `parent`
  If having multidimensional arrays `parent` can be used to access items of the parent array.
  For the first array `parent` will be equal to `root`. For the next levels `parent` will be equal to `item` of the parent array.
  All property values in `items` that supports expressions can use `parent`.

  ```json theme={null}
  "tabs": {
    "type": "array",
    "input": "{p.tabs}",
    "var": "tab",
    "items": {
      "type": "object",
      "properties": {
        "title": "{tab.title}",
        "content": "{tab.content}",
        "subTabs": {
          "type": "array",
          "input": "{tab.tabs}",
          "var": "subTab",
          "items": {
            "title": "{parent.title}: {subTab.title}",
            "content": "{subTab.content}",
          }
        }
      }
    }
  }
  ```

***

## object

Mapping of an object.

### Fields

| Property     | Required? | Description                       |
| ------------ | --------- | --------------------------------- |
| `type`       | **Yes**   | The property type - here `object` |
| `properties` | **Yes**   | The properties of the object      |

### Examples

```json title="Property type: object" theme={null}
"item": {
  "type": "object",
  "properties": {
    "title":  "{p.title}",
    "content": "{p.content}"
  }
}
```

***

## reference

Referencing another schema.

The reference property type is a bit different than string, number, boolean, etc.

This property types allows referencing other views created from either this Source Entity or from another source entity.

When referenced Enterspeed will resolve the view when requested by the Delivery API, so that the data will stay up-to-date.

In order to reference desired source entity, you can use `alias` of the schema and `id` or `originId` of the source entity and optionally a different source than the current source entity.

<Tip>
  Reference schemas are typically used when you are mapping data from another entity. Eg. a page has a reference another page entity or media entity.

  Read more about reference schemas [here](/enterspeed/key-concepts/referencing-schemas)
</Tip>

### Fields

| Property   | Required?    | Description                                                                                                                                                                                                                                                                                                                               |
| ---------- | ------------ | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| `type`     | **Yes**      | The property type - here `alias`                                                                                                                                                                                                                                                                                                          |
| `alias`    | **Yes**      | The alias of the schema you wish to reference                                                                                                                                                                                                                                                                                             |
| `id`       | **Yes** / No | The id of the source entity. `originId` can be used instead                                                                                                                                                                                                                                                                               |
| `originId` | **Yes** / No | The originId of the source entity. `id` can be used instead                                                                                                                                                                                                                                                                               |
| `source`   | No           | Allows you to define a different source. The source should be equal to the desired source group alias, where the view is located.<br /><br />If not defined, it uses the current source group.<br /><br />Note: This property is only used if `originId` is used. If `id` is used the source of the id will take priority over the source |

### Examples

```json title="Property type: reference (static value) with originId" theme={null}
"seoData": {
  "type": "reference",
  "originId": "{originId}",
  "alias": "Seo",
  "source": "anotherSourceGroupAlias"
}
```

```json title="Property type: reference (static value)" theme={null}
"seoData": {
  "type": "reference",
  "id": "{id}",
  "alias": "Seo"
}
```

```json title="Property type: reference (dynamic value)" theme={null}
"seoData": {
  "type": "reference",
  "id": "{id}",
  "alias": "{p.seoAlias}"
}
```

The `alias` can either be a static value, like "Seo" or it can be a dynamic value being resolved from the Source Entity that is being processed by Enterspeed. This allows for supporting almost any use case.

### Reference response

The response of references differs in V1 and V2+ of the Delivery API. V1 return the id, type and wraps the properties from the referenced view in a `view` property. The response of references in V2+ is much more clean and only return the actual properties from the referenced schema. If a reference is not found in V2+ the reference information are added in the `missingViewReference` property in the `meta` object for debug purpose.

```json title="Delivery API V1 uses a nested view property" theme={null}
{
  // This example shows a response of a view with two schema references.
  // image1 is referencing a found view with a url and name property
  // and image2 is referencing a view that doesn't exist.

  "meta": {
    "missingViewReferences": []
  },
  "route": {
    "image1": {
      "id": "gid://Environment/8ef2bdc0-c352-4190-a344-c51d1f5e72ea/Source/dc5d9518-b96a-428a-a9b3-31fb601376c2/Entity/1234/View/image",
      "view": {
        "url": "https://test.com/how-to-write-a-good-blog-post.png",
        "name": "How To Write A Good Blog Post"
      },
      "type": "ViewReference"
    },
    "image2": {
      "id": "gid://Environment/8ef2bdc0-c352-4190-a344-c51d1f5e72ea/Source/dc5d9518-b96a-428a-a9b3-31fb601376c2/Entity/1235/View/image",
      "view": null,
      "type": "ViewReference"
    }
  }
}
```

```json title="Delivery API V2+ only returns the actual view properties" theme={null}
{
  // This example shows a response of a view with two schema references.
  // image1 is referencing a found view with a url and name property
  // and image2 is referencing a view that doesn't exist.

  "meta": {
    "missingViewReferences": [
      {
        "path": "image2",
        "viewId": "gid://Environment/8ef2bdc0-c352-4190-a344-c51d1f5e72ea/Source/dc5d9518-b96a-428a-a9b3-31fb601376c2/Entity/1235/View/image"
      }
    ]
  },
  "route": {
    "image1": {
      "url": "https://test.com/how-to-write-a-good-blog-post.png",
      "name": "How To Write A Good Blog Post"
    },
    "image2": null
  }
}
```

***

## partial

Referencing a partial schema to map the data into.

The partial mapping property type allows for dynamically including partial schemas into the main schema. This is useful when you need to iterate an array of different objects that has an identifier, like an ID, alias or similar.

<Tip>
  Partial schemas are typically used when you want a reusable schema for mapping data that is part of the same entity. Eg. meta data (title, description, ...) is the same across different entity types but the data lives on the entity it self.

  Read more about partial schemas [here](/enterspeed/key-concepts/partial-schemas)
</Tip>

### Fields

| Property | Required? | Description                                   |
| -------- | --------- | --------------------------------------------- |
| `type`   | **Yes**   | The property type - here `partial`            |
| `input`  | **Yes**   | Defines what goes into the partial schema     |
| `alias`  | **Yes**   | Is used to resolve what partial schema to use |

### Examples

```json title="Property type: partial" theme={null}
"blocks": {
  "type": "array",
  "input": "{p.contentBlocks}",
  "items": {
    "type": "partial",
    "input": "{item}",
    "alias": "Block-{item.contentType}"
  }
}
```

The `input` defines what goes into the partial schema and the `alias` is used to resolve what partial schema to use. So in this case we could have partial schema with alias: Block-headline.

<Tip>
  If you want to pass the entire current source entity to input, you can use `{root}`.
</Tip>

***

## dynamic

### Fields

| Property | Required? | Description                      |
| -------- | --------- | -------------------------------- |
| `*`      | **Yes**   | [Path selector](./path-selector) |

### Examples

```json title="Property type: dynamic" theme={null}
"blocks": {
  "*": "p.contentBlocks"
}
```
