Then you can delete your Sequelize models and change the index file.
const { createAgent } =require('@forestadmin/agent');const { createSqlDataSource } =require('@forestadmin/datasource-sql');// Create agent and import collections from SQL databaseconstagent=createAgent(options).addDataSource(createSqlDataSource('postgres://user:pass@localhost:5432/myDatabase'),);
Then, depending on your database structure, you may need to rename both your tables and columns: the new agent will use the same names as your database, but depending on your previous Sequelize configuration, Sequelize may have renamed all tables and fields to camelCase.
Renaming tables and fields can be done by following this example:
// Convert snake_case to camelCaseconsttoCamelCase= name =>name.replace(/(_\w)/g, k => k[1].toUpperCase());constagent=createAgent(options)// If your collection names do not match between the old and new agent// you can rename them using the `rename` option of the `addDataSource` function.// Note that in your code, you will use the camelCase names..addDataSource(createSqlDataSource('postgres://user:pass@localhost:5432/myDatabase'), { rename: toCamelCase, })// If your field names do not match between the old and new agent// you can rename them using the `renameField` function on all fields.// Note unlike with collection names, which are renamed in the internal representation,// you will still need to use the unrenamed field names in your code..use(async ds => {for (constcollectionofds.collections)for (constfieldofObject.keys(collection.schema.fields))collection.renameField(field,toCamelCase(field)); });