Smart relationship for a smart collection

I am following the guide to add a smart relationship (has many) for a smart collection. Tell me it’s possible :pray:

Feature(s) impacted

Smart relationship, smart collection

Observed behavior

The new ‘versions’ (my smart relationship name) section is visible on the UI but it says ‘There are no versions yet.’. There are no requests sent to the /smart-collection/:id/relationships/versions, I only see the regular /smart-collection/:id requests.

Expected behavior

The requests to the /smart-collection/:id/relationships/versions are sent and the data returned is displayed on the UI.


forest-express-sequelize: “8.3.0”

Hello @Tatsyana_Slabodchyka

Can you show me the declaration code of the smart relationship?
(I’ll try to replicate on a test project)

Yes, sure!

const collectionFields = [
// ..., all the 'regular' fields
    field: 'versions',
    type: ['String'],
    reference: '', // reference to itself if it matters

Experiencing the same issue. Forest doesn’t seem to play nicely with relationships and “related data” views between 2 start collections.

It would be good if you guys can provide an example. The only examples provided are smart relationships on normal/sequelize collections

Hi @Antonio_Marino

I’m building a gist with an example.
Hopefully, everything works out and I can solve both your issues

1 Like

Here is an example with two smart collections which are linked by a smart relations in both ways (many to one / one to many).

There are two files which should go under the /routes folder, and two files for the /forest folder

To keep things simple

  • the collections are based on hardcoded data
  • I did not implement filtering, pagination etc…

I hope this solves the documentation gap that we have and that should get solved ASAP

And a screenshot of the result in the GUI

1 Like

It seems like this is exactly what I do (except I have only has-many relation). I see the request for the UI but then again - no requests for the related data itself

Hey @Tatsyana_Slabodchyka ,

Please find attached an example, you can see the relationships tag added, explaining how to retrieve the associated articles linked to my smart collection. It basically provides a link where to fetch the related article ( /forest/test1/0/relationships/articles ) You will need to edit the data returned from your route after they have been serialized.

Do you confirm it’s working on your end?

1 Like

Just to clarify: I added the relationships property to the ‘/:id’ route (not to the ‘/’)

1 Like