Migration to @forestadmin/agent - Display an array of references as related data

We are migrating to the latest node agent.

We have a collection containing an array of references to another collection and want to display it as Related Data. In the previous agent this was not a problem because we were dealing with a custom collection and we overrode every routes (including smart relationship routes), so we were able to implement the correct query behavior for this particular relationship.

In the new agent though, event though we still have custom collections we are unable to declare this kind of relationship.

Here the order of references is important, that is why a classic One-to-Many relationship is not a suitable answer.

Feature(s) impacted

Smart Relationships

Observed behavior

Cannot display an array of references as Related Data of target Collection.

Expected behavior

I think we should be able to override the relationship query mechanism to fit this use case

Context

  • Project name: pinpo-forest-admin-next
  • Team name: Operations
  • Environment name: Development
  • Agent technology: nodejs
  • Agent (forest package) name & version: “@forestadmin/agent”: “^1.45.0”,“@forestadmin/datasource-toolkit”: “^1.38.0”,
  • Database type: Custom (Translation strategy)

Hello @fbeiger ,

Have you tried to define manually the relationship with addOneToManyRelation ? This is the new way of creating smart relationships in the latest agent.

If this doesn’t work, can you provide a bit more information about your usecase ? How do you need to use the order information ?

Kind regards,

Actually I implemented the query from scratch.

My use case is: I have a Script collection containing an array of EngagementFormField references inside the fields field.

Because the data source is 100% custom I can create a “dummy field” (containsManyFilter) on EngagementFormField to use along with the forest experimental plugin filteredOneToMany to achieve this:


image

From this, in my collection list method, I perform the custom query whenever containsManyFilter is used in filter.

1 Like