Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Forestadmin with Typescript project and MongoDB Atlas Free Plan #494

Open
deltakroneker opened this issue Feb 15, 2021 · 0 comments
Open

Comments

@deltakroneker
Copy link

Expected behavior

Forestadmin, when initiated, recognizes all models and it can be used as CMS for adding fields directly to the DB.

Actual behavior

Forestadmin when initiated

  1. locally with local database shows just a subset of fields that each Mongo collection has
  2. locally with remote (dev) database (Mongo Atlas) shows only "id" fields

Stack

  1. We use Heroku for deployment, and a month ago we had to transition from mLab MongoDB provider due to Heroku’s breaking up with mLab company, so we successfully transitioned to Mongo Atlas provider and just updated the URL in the app. Mongo Atlas has free and paid plans and we are currently on the free plan.
  2. We use Typescript instead of plain Javascript in Foodtrucker app for more robust approach and type system, and instead of the usual:

models/user.js

structure we have a different file and folder structure with Onion architecture, grouped by features, not by models/controllers etc. such as:

user/user.model.js
user/user.interface.js

Trying the integration

So when I installed Forest admin (FA in short) for the first time on my local machine to test out the UI, I realized that the FA app didn’t recognize all models from the database it connected to, because the Mongo Atlas free plan does not support script execution of some sort which would allow this.
And then I found out official FA blog post which describes that instead of buying paid plan, you can actually avoid this known issue just by building the app locally first, and then somehow rewiring it to point into your real database, and thus creating the models locally needed but point to the real DB after that.

So I thought okay, it’s a hack - but let’s try it. And then I realized an even bigger problem, it looks like that it can be done locally, but the models in the FA dashboard only have fields that the DB has, not all that is defined in the DB.
Explained simply, even though I had defined isComingSoon field for Brands in my model file until an object in the DB has that property, forest admin does not know it exists.

So I thought, okay the FA needs to have files from which it can know the proper database structure. And I saw that the FA app has a copy of my model files, but the thing is - they are javascript files, not typescript.
I spent the last few days trying to:

  1. add our existing TS files …
  2. add our compiled JS files …
  3. manually rewrite our TS -> JS files …
    …into FA folder structure to try and see whether dashboard will see all fields, but no success to run the app.

I think the combination of Typescript and ForestAdmin is a problem, and to add to that, this issue with Mongo Atlas. There is just a lot of variables included and I am not that experienced with this framework to know whether we can run a dashboard on a TS project just by changing the DB provider or something like that.

Questions

Is this possible to use FA with a complex project structure like this?
Does Forestadmin gets all information on models from the files you put in the folder structure, and can they be TS files from my actual project?
Since we are using Heroku, I think the FA app needs to be clearly separated from the actual backend app so that it can be deployed, so my question would be, does that mean that on every model update in the actual project, I'd need to add those changes to model files in the FA project?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant