---
title: Comment définir une entité native comme propriété custom ?
slug: oip-next/s74mxqbawrbr0onpfpyop
description: Discover how to add a custom property to a native or custom entity in OIP by specifying the type as `schemaOIP: "OIP Entity Name"`. For instance, learn how to configure the oip.config.mjs file to add the Address entity as a property and access it seamless
icon: {"lucideIcon":"📘"}
createdAt: 2023-10-04T12:33:16.000Z
---

lorsqu'on ajoute une popriété custom à une entité native ou custom qui correspont à une entité native de l'OIP, le type de la propriété doit etre le suivant :  `schemaOIP: "Nom de l'entité OIP" `

Par exemple, pour ajouter l'entité Address en propriété d'une entité custom, il faut dans le fichier oip.config.mjs faire :&#x20;

:::CodeblockTabs
oip.config.mjs

```javascript
export default {
  ...ConfigGlobal,
  entities: {
    CustomEntity: {
      entity: CustomEntity,
      actions: {
        loadHandler,
        saveHandler
      },
      parents: ['project', 'customer'],
      schema: {
        firstName: { type: String },
        lastName: { type: String },
        secret: { type: String },
        address: { schemaOIP: 'Address' } 
      }
    }
  }
```
:::

Ici on a ajouter l'entité Address comme propriété de notre entité custom.

Pour y acceder, on utilise le fonctionnement habituel des entités

```javascript
const projectEntity = await Entities('Project').create();
const customEntity = await Entities('CustomEntity').get(projectEntity)
const address = await Entities('Address').get(customEntity);
```

### Comment ajouter une relation vers une entité native sous forme de tableau ?

Si vous voulez ajouter une relation vers une entité native sous forme de tableau, il faut l'indiquer dans votre déclaration de l'oip config de cette manière :

```javascript
export default {
  ...ConfigGlobal,
  entities: {
    CustomEntity: {
      entity: CustomEntity,
      actions: {
        loadHandler,
        saveHandler
      },
      parents: ['project', 'customer'],
      schema: {
        firstName: { type: String },
        lastName: { type: String },
        secret: { type: String },
        addresses: { type: Array, items: {schemaOIP: 'Address'} } 
      }
    }
  }
```

Ici, on ajouter une relation vers l'entité address sous forme de tableau.
