Custom Field Values of Nested Model Not Loading

Feature(s) impacted

I included a repo to illustrate my problem:

The custom field of a nested model is not loading, when placed as a reference for that nested model.

Observed behavior

With my repo:

  1. in the layout, set fullAddress as the reference field for “clients_address”.
  2. Create a new client
  3. For that client fill in the address
  4. Go to that client’s detail view.

You will should see the address relationship is falsely displayed with “null, null null”

Expected behavior

Instead I would expect the relationship to appear with “Street Nr, Postal Code Municipality”

Failure Logs



Can be extracted from the repo.

Hello @David_Roegiers,

Thanks for reaching out and for the repo :raised_hands:

Sorry to hear you’re facing this inconvenience.
I’m going to try to reproduce on my side and I’ll get back to you.


1 Like


You will see, in my repo, that I have configured the flattener for the mongoose model as follows:

clients model

address: {
 street: string,
 municipality: string

clients flattenOptions

    asModels: ['address']

Are non-array nested object fields in the data model, allowed to be flattened as models?

In that case, sorry for the false bug report. I did not get it from your documentation, that this is a no-go. Anyway, that is what I did and might the reason why we are seeing this behaviour. Moreover, it causes another bug on creation of a new address. If this is indeed not supported behaviour, maybe might be cool to implement a fail-safe informing the developer through an error, that this sort of configuration is not possible, i.e. only array fields may be configured asModels.

FYI @jeffladiray

Hello @David_Roegiers,

I’m taking over this subject. Thanks a lot for the minimal example reproducing your issue. I’ll investigate on my side and get back to you.

1 Like

For information, I’m working on a fix on your first problem regarding the computed field “full address” not being correctly retrieved when used as a reference field.

Using asModels on a non-array field should be supported because it’s not a lot different from using it on array fields. Right now it seems to have some limitations, but we’ll fix them.

I’ll work on a second fix regarding the creation when the first one will be released.

Please note though that address creation will only be possible on an existing client: as addresses are attached to client objects, it won’t be possible to create an address first, and then a client.

Okay, thanks @GuillaumeGautreau.

That’s good to hear. It would be helpful to use asModels on a non-array field. I will apply this to visually improve the structure of the Details view of field-heavy collections.

I’ll wait for your fixes then.

That makes sense. Is there a way to programmatically avoid this option to appear in the UI? Our operators will find it and then report this as a bug.

Hello @David_Roegiers,

We released @forestadmin/datasource-mongoose@1.5.15 fixing the issue with computed fields. You can upgrade to this version and use computed fields as expected.

Regarding the possibility to hide the address creation, I would suggest to not give the right to create addresses to users. You can remove this possibility in the roles tab in your project settings (once deployed in production or on a remote environment).

It might be useful though to create addresses along with clients, which is possible with the option … asFields but at the moment you cannot use both asFields and asModels at the same time on the same field.

I think it might be possible using the flattener plugin (see the docs here) in addition to asModel. But right now we have the same creation bug than the one we need to fix.

I’ll let you know once done.


We released @forestadmin/datasource-mongoose@1.5.17 that fixed the issue with record creation and retrieval.

Could you please give it a try?

Thanks @GuillaumeGautreau

I’m just waiting for this fix to be merged, and then I will try them both out in the afternoon, if it’s ready by then.


Sorry for the late reply, I was focused on some other threads.

So, I’m running @forestadmin/datasource-mongoose:1.5.19.

There is a non-array nested object field of my MongoDB data model, called x. I added x to the asModels array of the built-in field flattener for that model.

Unfortunately, when I navigate to the computed record, which corresponds to that field x (detail view), the server freezes, i.e. the HTTP request stalls.

Any idea why this might be the case?

Let me add some more information, on top of the analogy I described earlier (with the flattened model field x):

This FA server request works:

While, this FA server request stalls:

The logs don’t say anything, and I haven’t customized the lawyers_x collection.


It’s not much information, but maybe you can suggest me a line number in the distribution, where to put a breakpoint (js, not ts) and share some variable data?

It seems, that the issue might be coming from something else. I’m investigating and will get back to this thread.

So, the faulty behaviour is happening, if I upgrade @forestadmin/datasource-mongoose from 1.5.15 to 1.5.16. I once saw a MongoPoolClearedError, but I am not certain if this is the culprit.

In this situation, I can not upgrade past 1.5.15 to test the new functionality, so we would need to fix this, before I can mark this issue as solved.

So, I can confirm, that this is working with version 1.5.15 and will mark this issued as Solved.

Nonetheless, I can’t upgrade beyond that, which is OK for me now, since I don’t have the issue about the field creation any more.

Still would be great if this freezing behaviour gets tackled at some point.

Hello @David_Roegiers,

Is it possible to share a repository that reproduces this bug, as you did with the previous one? On my side when I navigated to records everything worked smoothly so I would need more info to reproduce the issue.