After a migration from V5 to V8 Relationship/references are empty on table view
Feature(s) impacted
Relationship/references on table view
Observed behavior
Relationship/references on table view, cells are empty, on record detail it is ok
Expected behavior
Relationship/references on table view, cells must be filled
Failure Logs
In my production V5 :
In my dev + staging V8 :
On the debugguer relationships datas are not filled
When i enter the record relationships are ok :
Context
- Project name: Seeuletter - API
- Team name: Admin
- Environment name: Development or Staging
- Agent type & version: 8.5.0
- Recent changes made on your end if any: v5 → v8
Hi @Olivier_BESSON1,
Can you please share your server logs?
From v5 to v8, there was a lot of breaking changes.
Maybe it’s related to a RecordGetter/ResourceGetter
signature change.
Just to be sure, can you go to the settings of the company model in the GUI, and check which reference field is selected?
I find it surprising that it is working on the record detail view
1 Like
Hi @anon39940173
Sorry for the late response, i wasn’t at work last week
The reference field selected is “name” :
A strange but interesting fact is that sometimes - maybe 1% of times - the relation ship is displayed but only for the first record of the table.
It happend this morning and i took a screen, it’s the same backend version and process that replied to these 2 calls :
On the record the relation are ok, they are for all fields of the record, event thoses outside the screen.
Hi @Sliman_Medini
Not sure what you mean by “my server logs” ?
When i opened a tab view on letters, here are my console logs on my api :
7|API | 2022-03-01T09:22:17.632Z app:Utils Started POST on /api/forest/authentication
7|API | 2022-03-01T09:22:17.638Z app:Utils Ending POST on /forest/authentication with status 200 in 6ms
7|API | forest called
7|API | forest called
7|API | 2022-03-01T09:22:19.138Z app:Utils Started GET on /api/forest/authentication/callback
7|API | 2022-03-01T09:22:19.437Z app:Utils Ending GET on /forest/authentication/callback with status 200 in
298ms
7|API | forest called
7|API | forest called
7|API | 2022-03-01T09:22:19.464Z app:Utils Started GET on /api/forest/Letters
7|API | 2022-03-01T09:22:22.498Z app:Utils Ending GET on /forest/Letters with status 200 in 3032ms
7|API | forest called
7|API | forest called
7|API | 2022-03-01T09:22:22.555Z app:Utils Started GET on /api/forest/Letters/count
7|API | 2022-03-01T09:22:22.660Z app:Utils Ending GET on /forest/Letters/count with status 200 in 103ms
Hi @anon39940173 @Sliman_Medini can you help me please.
If it can help to find the solution, we can make a team/zoom/slack/other on my dev env
Hey @Olivier_BESSON1
Would it. be possible to have:
- The request payload for the list view that is missing the relationships (The request associated with the “debugguer relationships datas are not filled” screenshot)
- The definition of the “Letters” mongoose model
- If you did modify it, the definition of the
.get('/letters', ...)
route
- Any browser/admin backend error you may encounter.
Feel free to reach me via DM if you consider these informations private
Thanks in advance.
Hi @jeffladiray i just asked these informations from the lead dev that did the upgrade, we’ll come back soon to you
Hello,
The issue comes from the Mongoose Model name and Collection name. In this case, the Mongoose model name (so generated into the .forestadmin-schema.json) is “Companies” and the collection name is “companies” (lower case).
It seems that the solution here is to have the same Model name as the collection Mongo. Can we have an alternative solution to fix this ?
Thanks
Hi @Florian_PONTHUS,
Thank you.
Can you please confirm that your issue is fixed now? (at least with a workaround)
Does the table view issue “not showing the references” raised by Olivier is fixed when the model name is strictly equal to the collection name?
Please note that:
The mongo collection name can be different from the mongoose model name.
The model name in the references fields must be strictly equal to the model name as it is declared.
For example, the following model is working:
Another idea: your documents must have the references defined as ObjectId, like the _id fields.
Note: please check your entire server log while starting. If there is an error in references, it is shown at startup.
Best regards
Hi !
The issue isn’t fixed so far. But I confirm that the issue is fixed when the model name is stricly equal to the collection name. However, it’s not safe for us to change either the model name or the collection name in MongoDB.
I try to pass the collection into the Mongoose.model method like you did, but my .forestadmin-schema.json always generates a collection with name corresponding to the model name (“Letters” in my case). So apparently the collection name argument isn’t the solution.
There is another solution to define different model and collection name in Forest ?
Thank you,
Hi @Florian_PONTHUS,
This is strange because mongoose.model(...
with 3 parameters comes from the mongoose interface.
the mongoose documentation provide 3 ways to define the collection name. As an alternative, you can do:
const Letters = new mongoose.Schema<LetterDocument>(...);
Letters.set('collection', 'collectionName');
Please take care that the documentation link is for mongoose version 6.2.7, you maybe need to browse to match your version.
Hello @Olivier_BESSON1
Did you, by any change, figure out a way to solve your issue ? Do you need any additional help ?
Steve.