Models
⚠️ This page and sub-pages are relevant only if you installed Forest Admin directly on a database (SQL/Mongodb). If you installed in a Rails/Django/Laravel app, you manage your models like you normal
Please be sure of your agent type and version and pick the right documentation accordingly.
This is the documentation of the forest-express-sequelize and forest-express-mongoose Node.js agents that will soon reach end-of-support.
forest-express-sequelize v9 and forest-express-mongoose v9 are replaced by @forestadmin/agent v1.
Please check your agent type and version and read on or switch to the right documentation.
This is still the latest Ruby on Rails documentation of the forest_liana agent, you’re at the right place, please read on.
This is the documentation of the django-forestadmin Django agent that will soon reach end-of-support.
If you’re using a Django agent, notice that django-forestadmin v1 is replaced by forestadmin-agent-django v1.
If you’re using a Flask agent, go to the forestadmin-agent-flask v1 documentation.
Please check your agent type and version and read on or switch to the right documentation.
This is the documentation of the forestadmin/laravel-forestadmin Laravel agent that will soon reach end-of-support.
If you’re using a Laravel agent, notice that forestadmin/laravel-forestadmin v1 is replaced by forestadmin/laravel-forestadmin v3.
If you’re using a Symfony agent, go to the forestadmin/symfony-forestadmin v1 documentation.
Please check your agent type and version and read on or switch to the right documentation.
Models
Your models are located in /models. They control a big part of your Forest UI.
Reflecting your database changes in your UI
When you install for the first time, Lumber introspects your database and generates your models accordingly.
Afterwards, here's how your database changes can be rendered in your Forest UI:

Updating your models automatically
If you made many changes or even added a new table/collection, we recently reintroduced a programmatic way to help you manage the associated file changes:
This feature requires an agent version 7 or higher.
Version 2.2+ of Forest CLI allows you via its schema:update command to:
Generate files which, after introspecting your database, appear to be missing in your folders (
models,routes&forest). Eg. Adding a new table and launchingschema:updatewithin your project directory should generate the associated models/routes & forest filesGenerate a correct project architecture to easily manage multiple databases. After your onboarding (on a single database), update the
config/databases.jsfile to add a new connection, launchschema:updateand your models should be set correctly
forest schema:update will never modify your code base (remove files, move files, change file content). It's up to you to copy some (or all) of the generated contents into your existing files/folders.
Note that forest schema:update options are as follows:
-cor--config, allowing to specify a path for the config file to user (Default to./config/databases.js)-oor--output-directory: Create a directory named after the config parameter provided. It will also redump all themodels/routes/forestfile in a specific directory, allowing the end-user to pick code modification.
This command need to be launched at the root of the project directory, where the .env should be, since it is required by config/databases.js file.
Enriching your models
Lumber does some of the work for you. However, you remain in control of your models.
On the following page, we'll cover how you can enrich your models:
Enrich your modelsThe .forestadmin-schema.json file
.forestadmin-schema.json fileOn server start, a .forestadmin-schema.json file will be auto-generated in local (development) environments only. It reflects:
the state of your models (in
/models).your Forest Admin customization (in
/forest).
A consequence of the above is, in Production the .forestadmin-schema.json file does not update according to your schema changes.
Do not edit this file, as it could break your interface if the wrong syntax is used.
Versioning the.forestadmin-schema.json file will also help you visualize your changes:

Last updated
Was this helpful?