Integration of a second database

so I separated in two folders one for my 1st database and the other for the 2nd.
image

However when I go to forest admins I still don’t see my first database.

Is it necessary to modify something else so that they can see my 1st and 2nd database?
Because when I launch npm start, in my .forestadmin-schema.json file I can’t find my first database

can you show me the code in config/databases.js ?

You need to:

  • Change the name of either database (both are called defaults, so the second one is probably overwriting the first one when sequelize loads)
  • Update the modelsDir key

Here is the configuration in the config/databases.js file

for the name of the files are they correct.
And I did not understand how to update the modelsDir key

can you rename name: 'default' to name: 'anythingelse' on the second record?

1 Like

Yes, that was the problem ! I changed the default by anythingelse in name and now I have the two bases visible on forest !
Thank you @anon39940173 !

Finally :slight_smile:

Sorry again for the long delay on getting this sorted out

1 Like

No problem ! :slight_smile:
I have a last question is it possible to separate the data of my different databases by putting them in a folder for each of them?

For example in the folder routes I have the routes of the two databases together.
Is it possible to put folder like for the models?

Sure thing.
Just create the folders, it should work out of the box without changing any code.

If not, you can play with this piece of code in /app.js:
image

Do you have a document explaining this part? :sweat_smile:

I don’t think so :man_shrugging:

The agent requires all routes under the routes folder recursively using require-all

Creating folder there should just work out of the box.

Did you attempt it and had issues?

yes I created a folder and moved one of my routes into the folder. It works if I comment

const { assistance } = require(‘…/…/models’);

otherwise I get an error saying that it can’t access the models while the route is in ../../models

I think it’s ok actually I just need to change the path like this

const assistance = require(‘…/…/models/np/assistance’);

So it works fine