# Naming conflicts

{% hint style="success" %}
This is the official documentation of the `@forestadmin/agent` Node.js agent.
{% endhint %}

#### Collection naming collisions

When importing collections to an admin panel, you may encounter naming collisions.

You can tackle them by renaming the collection that is causing issues.

There are two ways to rename collections: either provide a plain object which maps the old names to the new names, or a function which does the same.

Don't worry about leaving naming collisions: your development agent will warn you and crash at startup.

```javascript
const { createAgent } = require('@forestadmin/agent');
const { createSqlDataSource } = require('@forestadmin/datasource-sql');
const { toPascalCase } = require('./utils');

const agent = createAgent(options);
const sqlDataSource = createSqlDataSource(
  'postgres://user:pass@localhost:5432/mySchema',
);

// Rename sqlDataSource collections by providing replacements
agent
  // Rename the `customers` and `stores` collections.
  // Note that other collections won't be renamed.
  .addDataSource(sqlDataSource, {
    rename: {
      customers: 'customersFromFrenchBranch',
      stores: 'storesFromFrenchBranch',
    },
  })

  // Renaming collection can also be done by providing a function.
  // All collections will be renamed (the handler is called once per collection)
  // This example is pretty usefull if you are migrating an old project following our migration guide
  .addDataSource(sqlDataSource, {
    rename: underscoreCasedName => toPascalCase(underscoreCasedName),
  });
```

#### Field naming collisions

You can tackle them by renaming the fields that are causing issues too.

Use the [renameField method](https://docs.forestadmin.com/developer-guide-agents-nodejs/agent-customization/fields/import-rename-remove#renaming-and-removing-fields-and-relations) to change the name inside your forestadmin-schema.

{% hint style="info" %}
We have developed an additional plugin to tackle this issue more easily: [@forestadmin-experimental/plugin-rename-all-fields](https://www.npmjs.com/package/@forestadmin-experimental/plugin-rename-all-fields)
{% endhint %}

{% tabs %}
{% tab title="TypeScript" %}

```typescript
import renameAllFields, {
  snakeToCamelCase,
} from '@forestadmin-experimental/plugin-rename-all-fields';

agent
  // Add all your datasources then ...
  ...
  // Renaming fields
  // All field will be renamed (the handler is called once per field)
  .use(renameAllFields, snakeToCamelCase);
```

{% endtab %}

{% tab title="JavaScript" %}

```javascript
const { default: renameAllFields, snakeToCamelCase } = require('@forestadmin-experimental/plugin-rename-all-fields');

agent
  // Add all your datasources then ...
  ...
  // Renaming fields
  // All fields will be renamed (the handler is called once per field)
  .use(renameAllFields, snakeToCamelCase);
```

{% endtab %}
{% endtabs %}
