ForestAdmin / agent-nodejs

🌱 Node.js agent for Forest Admin
GNU General Public License v3.0
67 stars 8 forks source link

Issue with subdocuments and JSON editor #513

Closed john-evan08 closed 2 years ago

john-evan08 commented 2 years ago

Expected behavior

Screenshot 2022-10-25 at 16 06 55

I have a mongoose schema with subdocuments containing subdocuments. (level = 3) When there is just one level of subdocuments, the first level estimate sub field type and put default widget on it. ✅

Actual behavior

But in my case (3 levels), forest admin just set a json editor widget to edit it. How to flatten the nested subdocuments so I can see them in related data with the suitable widgets ?

Failure Logs

Here is my JSON view in forest admin whereas I want the "blocks" to be in related data.

Screenshot 2022-10-25 at 16 09 46

Context

jeffladiray commented 2 years ago

Hello @john-evan08 :wave:

You should be able to use our asModel option to flatten nested fields within a mongoose model (See this documentation)

Let me know if that helps

john-evan08 commented 2 years ago

Hello @jeffladiray ,

Thanks for your quick answer. It works !

jeffladiray commented 2 years ago

Good to know :)

I'm closing the issue then.

In the future, don't hesitate to go to our community if you encounter any issues or if you have any questions. We tend to answer a bit faster there 👍