Naming conflicts
Collection naming collisions
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
Last updated